SlideShare a Scribd company logo
© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Inter Integrated Circuit (I2
C) Drivers
2© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
I2
C Prologue
I2
C Subsystem in Linux
I2
C Client Driver
I2
C Device Registration (Non DT and DT)
3© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Prologue
Originally developed by Phillips (SMBus by Intel)
Suitable for small slow devices
I2
C is a 2-wire protocol
One Serial Clock
One Data Line
Popular in Desktops & Embedded Systems
Used for accessing
EEPROMs
RTCs
...
4© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Conditions
Start Condition
Master signals this condition to initiates the transfer
on the bus
Stop Condition
Master signals this condition to stop the transfer
ACK Condition
Master or Slave to acknowledge the receipt of
previous byte
5© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Transactions
Master begins the communication by issuing the
start condition.
Sends a 7/10 bit slave address followed by
read/write bit
The addressed slave ACK the transfer
Transmitter transmits a byte of data and receiver
issues ACK on successful receipt
Master issues a STOP condition to finish the
transaction
6© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Transactions...
Start
Data
1
SLA + W
Slave
ACK
Data
2
Data
N
Slave
ACK
Slave
ACK
Stop
Master Write
Slave
ACK
Start
Data
1
SLA
+ W
Slave
ACK
Repeat
Start
Data
1
Slave
ACK
SLA +
R
Stop
Master Read
Master
ACK
Data
N
Master
NACK
7© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Character Driver Framework
User Space
App
open(), read(), write()
/dev/i2c_drv0
i2c_app.c, i2c_intr.c
my_open() my_read() my_write()
Char Driver
Low Level
I2
C Driver
i2c_char.c
i2c_read() i2c_write() test1.c,
s1.c, s2.c..
i2c_omap.c
(initialization
and utility
functions)
8© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
AM335x I2
C Registers
I2C_SA_REGISTER (Slave Address Reg)
I2C_CON_REGISTER (Configuration Reg)
Bits for enabling the I2
C module
Selecting the Fast / Standard mode of op
Selecting the Master / Slave config
Sending the Start / Stop conditions on the bus
I2C_DATA (RX/TX Data Reg)
I2C_BUF (FIFO Thresholds, DMA configuration)
I2C_CNT (Bytes in I2
C data payload)
I2C_IRQ_STATUS_REG
9© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
AM335X I2
C APIs
#include “i2c_char.h”
u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev,
int reg)
void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
int reg, u16 val)
u16 wait_for_event(struct omap_i2c_dev *dev)
void omap_i2c_ack_stat(struct omap_i2c_dev, u16 stat)
val = omap_i2c_read_reg(dev, OMAP_I2C_BUF_REG);
val |= OMAP_I2C_BUF_TXFIF
omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, val);
10© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Writing to EEPROM
For writing at EEPROM offset 0x0060
Send the start condition.
Send the Slave address of EEPROM (0X50),
followed by direction (Read/Write)
Send the EEPROM location higher byte, followed
by lower byte
Send the actual data to be written
Send the Stop condition
START->0x50->0x00(offset High)->0x60 (offset
Low)->0X95(Data)->STOP
11© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Reading From EEPROM
Write the EEPROM offset say 0x0060 (read offset)
START->0x50->0x00(offset High)->0x60 (offset Low)-
>STOP
Read the EEPROM data
Send the start condition.
Send the Slave address of EEPROM (0X50), followed
by direction (Read)
Read the data
Send the Stop condition
START->0x50->Data(RX)->Data(RX)->STOP
12© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Subsystem
I2C subsystem provides
API to implement I2
C controller driver
API to implement I2
C device driver in kernel space
An abstraction to implement the client drivers
independent of adapter drivers
13© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Subsystem ...
User Space
Kernel Space
I
2
C Device
(i2c_client)
I
2
C Host
Controller
(i2c_adapter)
I
2
C Bus
Hardware Space
/sys, /dev
User Applications
I
2
C User Mode
Device Driver
I
2
C Core
i2c-dev
I
2
C Adapter (platform_driver) / Algo Driver (i2c_algorithm)
Vertical: Character/SysFS
I
2
C Client Driver
Horizontal: I
2
C
(i2c_driver)
14© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Subsystem Details
i2c-adapter / i2-algo
Controller-specific I2
C host controller / adapter
Also called as the I2
C bus drivers
i2c-core
Hides the adapter details from the layers above
By providing the generic I2
C APIs
i2c-dev
Provides device access in user space through /sys
Enables implementation of User Mode Drivers
i2c-client
Driver specific to an I2
C device
Implemented using i2c-core APIs
15© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Driver Model
CPU
I
2
C Controller 1 I
2
C Controller 2 I
2
C Controller 3
I
2
C Adapter 1 I
2
C Adapter 2 I
2
C Adapter 3
I
2
C Client 1
/sys/bus/i2c
/sys/bus/platform
/sys/bus/platform/device/xx.i2c
/sys/devices/ocp.3/xx.i2c/
Platform Bus
/sys/bus/i2c/devices/i2c-n
I
2
C Client 2 I
2
C Client 3
I
2
C
Bus
/sys/bus/i2c/n-xx/i2c-n/devicen
16© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
SMBus
Subset of I2
C
Using only SMBus commands makes it compatible with
both adapters
Part of I2
C Core itself
APIs for Device Access (Header: <linux/i2c.h>)
int ioctl(smbus_fp, cmd, arg);
s32 i2c_smbus_write_byte(client, val);
s32 i2c_smbus_read_byte(client);
s32 i2c_smbus_write_*_data(client, cmd, val);
s32 i2c_smbus_read_*_data(client, cmd);
client – Pointer to struct i2c_client created by the probe function
17© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Client Driver
Typically a character driver vertical or /sys exposed
But actually depends on the device category
And the I2
C driver horizontal
Registers with I2
C Core (in the init function)
Unregisters from I2
C Core (in the cleanup function)
And uses the transfer function from I2
C Core for actual
data transactions
int i2c_transfer
(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
adap is the client->adapter
18© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Client Driver's init & cleanup
Registering to the I2
C Core using
int i2c_add_driver(struct i2c_driver *);
struct i2c_driver contains
probe function – called on device detection
remove function – called on device shutdown
id_table – Table of device identifiers
Unregistering from the I2
C Core using
void i2c_del_driver(struct i2c_driver *);
Common bare-bone of init & cleanup
Just use module_i2c_driver(struct i2c_driver);
19© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Client Driver's Registration
struct i2c_driver dummy_driver = {
.driver = {
.name = “dummy_client”,
.owner = THIS_MODULE,
},
.probe = dummy_probe,
.remove = dummy_remove,
.id_table = dummy_ids,
}
static const struct i2c_device_id dummy_ids = {
{ “dummy_device”, 0},
{}
};
i2c_add_driver(dummy_driver);
20© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Adapter Driver
Registering to the I2
C Core using
int i2c_add_driver(struct i2c_driver *);
struct i2c_driver contains
probe function – called on device detection
remove function – called on device shutdown
id_table – Table of device identifiers
Unregistering from the I2
C Core using
void i2c_del_driver(struct i2c_driver *);
Common bare-bone of init & cleanup
Just use module_i2c_driver(struct i2c_driver);
21© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Checking Adapter Capabilities
I2
C client driver's probe would typically check for
HC capabilities
Header: <linux/i2c.h>
APIs
u32 i2c_get_functionality
(struct *i2c_adapter);
int i2c_check_functionality
(struct *i2c_adapter, u32 func);
22© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
I2
C Client Driver Examples
Path: <kernel_source>/drivers/
I2
C EEPROM: AT24
misc/eeprom/at24.c
I2
C Audio: Beagle Audio Codec cum Pwr Mgmt
mfd/twl4030-audio.c -> mfd/twl-core.c(plat driver)
I2
C RTC: DS1307
rtc/rtc-twl.c -> mfd/twl-core.c; rtc/rtc-ds1307.c
Browse & Discuss any
23© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Registering an I2
C Client (Non DT)
On non-DT platforms, the struct i2c_board_info
describes how device is connected to a board
Defined with I2C_BOARD_INFO helper macro
Takes as argument the device name and the slave
address of the device on the bus.
An array of such structures is registered on per
bus basis using the i2c_register_board_info
during the platform initialization
24© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Registering an I2
C Client (Non DT)..
static struct i2c_board_info my_i2c_devices [] = {
{
I2C_BOARD_INFO (“my_device”, 0 x1D ),
. irq = 70,
.platform_data = &my_data },
};
i2c_register_board_info (0, my_i2c_devices ,
ARRAY_SIZE ( my_i2c_devices ));
25© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Registering an I2
C Client (DT)
In the device tree, the I2
C devices on the bus are
described as children of the I2
C controller node
reg property gives the I2
C slave address on the
bus
26© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Registering an I2
C Client (DT) ...
i2c@49607899 {
compatible = "dummy_adap";
clock-frequency = <0x186a0>;
#address-cells = <0x1>;
#size-cells = <0x0>;
my_dummy@0 {
compatible = "dummy_device";
reg = <0x40>;
};
};
Registered internally by i2c_core based on info from DTB
i2c_new_device(struct i2c_adapter *, struct i2c_board_info *);
27© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
I2
C Prologue
I2
C Subsystem in Linux
I2
C Client Driver
I2
C Device Registration (Non DT and DT)
28© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

More Related Content

What's hot

Network Drivers
Network DriversNetwork Drivers
Network Drivers
Anil Kumar Pugalia
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
Houcheng Lin
 
Platform Drivers
Platform DriversPlatform Drivers
用Raspberry Pi 學Linux I2C Driver
用Raspberry Pi 學Linux I2C Driver用Raspberry Pi 學Linux I2C Driver
用Raspberry Pi 學Linux I2C Driver
艾鍗科技
 
Pcie drivers basics
Pcie drivers basicsPcie drivers basics
Pcie drivers basics
Venkatesh Malla
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
Anil Kumar Pugalia
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
Macpaul Lin
 
Linux I2C
Linux I2CLinux I2C
Linux I2C
KaidenYu
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
Houcheng Lin
 
I2c drivers
I2c driversI2c drivers
I2c drivers
Pradeep Tewani
 
Linux device drivers
Linux device drivers Linux device drivers
linux device driver
linux device driverlinux device driver
linux device driver
Rahul Batra
 
Linux dma engine
Linux dma engineLinux dma engine
Linux dma engine
pradeep_tewani
 
Linux PCI device driver
Linux PCI device driverLinux PCI device driver
Linux PCI device driver
艾鍗科技
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
Anil Kumar Pugalia
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
SUSE Labs Taipei
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
Block Drivers
Block DriversBlock Drivers
Block Drivers
Anil Kumar Pugalia
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 

What's hot (20)

Network Drivers
Network DriversNetwork Drivers
Network Drivers
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Platform Drivers
Platform DriversPlatform Drivers
Platform Drivers
 
用Raspberry Pi 學Linux I2C Driver
用Raspberry Pi 學Linux I2C Driver用Raspberry Pi 學Linux I2C Driver
用Raspberry Pi 學Linux I2C Driver
 
Pcie drivers basics
Pcie drivers basicsPcie drivers basics
Pcie drivers basics
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Linux I2C
Linux I2CLinux I2C
Linux I2C
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Linux dma engine
Linux dma engineLinux dma engine
Linux dma engine
 
Linux PCI device driver
Linux PCI device driverLinux PCI device driver
Linux PCI device driver
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Block Drivers
Block DriversBlock Drivers
Block Drivers
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 

Viewers also liked

Serial Drivers
Serial DriversSerial Drivers
File System Modules
File System ModulesFile System Modules
File System Modules
Anil Kumar Pugalia
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
Anil Kumar Pugalia
 
References
ReferencesReferences
References
Anil Kumar Pugalia
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
Anil Kumar Pugalia
 
Embedded C
Embedded CEmbedded C
Embedded C
Anil Kumar Pugalia
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
Anil Kumar Pugalia
 
Introduction to BeagleBone Black
Introduction to BeagleBone BlackIntroduction to BeagleBone Black
Introduction to BeagleBone Black
SysPlay eLearning Academy for You
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
SysPlay eLearning Academy for You
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
Anil Kumar Pugalia
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
Anil Kumar Pugalia
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
Anil Kumar Pugalia
 
Kernel Programming
Kernel ProgrammingKernel Programming
Kernel Programming
Anil Kumar Pugalia
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
SysPlay eLearning Academy for You
 
File Systems
File SystemsFile Systems
File Systems
Anil Kumar Pugalia
 

Viewers also liked (15)

Serial Drivers
Serial DriversSerial Drivers
Serial Drivers
 
File System Modules
File System ModulesFile System Modules
File System Modules
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
References
ReferencesReferences
References
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Introduction to BeagleBone Black
Introduction to BeagleBone BlackIntroduction to BeagleBone Black
Introduction to BeagleBone Black
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Kernel Programming
Kernel ProgrammingKernel Programming
Kernel Programming
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
 
File Systems
File SystemsFile Systems
File Systems
 

Similar to I2C Drivers

12_Shelf_Manager.pptx
12_Shelf_Manager.pptx12_Shelf_Manager.pptx
12_Shelf_Manager.pptx
nitin_009
 
SPI Drivers
SPI DriversSPI Drivers
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
chiportal
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
Mohammad Reza Kamalifard
 
Chapter 02 - Introduction to Switched Networks
Chapter 02 - Introduction to Switched NetworksChapter 02 - Introduction to Switched Networks
Chapter 02 - Introduction to Switched Networks
Yaser Rahmati
 
KPUCC-Rs instructor ppt_chapter2_final
KPUCC-Rs instructor ppt_chapter2_finalKPUCC-Rs instructor ppt_chapter2_final
KPUCC-Rs instructor ppt_chapter2_final
Fisal Anwari
 
CCNAv5 - S2: Chapter2 Basic Switching Concepts and Configuration
CCNAv5 - S2: Chapter2 Basic Switching Concepts and ConfigurationCCNAv5 - S2: Chapter2 Basic Switching Concepts and Configuration
CCNAv5 - S2: Chapter2 Basic Switching Concepts and Configuration
Vuz Dở Hơi
 
Chapter 13 : Introduction to switched networks
Chapter 13 : Introduction to switched networksChapter 13 : Introduction to switched networks
Chapter 13 : Introduction to switched networks
teknetir
 
Day 20.3 frame relay
Day 20.3 frame relay Day 20.3 frame relay
Day 20.3 frame relay
CYBERINTELLIGENTS
 
Icnd210 s08l03
Icnd210 s08l03Icnd210 s08l03
Icnd210 s08l03
computerlenguyen
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
Anil Kumar Pugalia
 
05 module managing your network enviornment
05  module managing your network enviornment05  module managing your network enviornment
05 module managing your network enviornment
Asif
 
CCNA 2 Routing and Switching v5.0 Chapter 2
CCNA 2 Routing and Switching v5.0 Chapter 2CCNA 2 Routing and Switching v5.0 Chapter 2
CCNA 2 Routing and Switching v5.0 Chapter 2
Nil Menon
 
managing your network environment
managing your network environmentmanaging your network environment
managing your network environment
scooby_doo
 
Day 20.1 configuringframerelay
Day 20.1 configuringframerelayDay 20.1 configuringframerelay
Day 20.1 configuringframerelay
CYBERINTELLIGENTS
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
imec.archive
 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016
Chris Simmonds
 
Np unit2
Np unit2Np unit2
Np unit2
vamsitricks
 
BitVisor Summit 11「2. BitVisor on Aarch64」
BitVisor Summit 11「2. BitVisor on Aarch64」BitVisor Summit 11「2. BitVisor on Aarch64」
BitVisor Summit 11「2. BitVisor on Aarch64」
BitVisor
 
Arduino programming
Arduino programmingArduino programming
Arduino programming
Siji Sunny
 

Similar to I2C Drivers (20)

12_Shelf_Manager.pptx
12_Shelf_Manager.pptx12_Shelf_Manager.pptx
12_Shelf_Manager.pptx
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
 
Chapter 02 - Introduction to Switched Networks
Chapter 02 - Introduction to Switched NetworksChapter 02 - Introduction to Switched Networks
Chapter 02 - Introduction to Switched Networks
 
KPUCC-Rs instructor ppt_chapter2_final
KPUCC-Rs instructor ppt_chapter2_finalKPUCC-Rs instructor ppt_chapter2_final
KPUCC-Rs instructor ppt_chapter2_final
 
CCNAv5 - S2: Chapter2 Basic Switching Concepts and Configuration
CCNAv5 - S2: Chapter2 Basic Switching Concepts and ConfigurationCCNAv5 - S2: Chapter2 Basic Switching Concepts and Configuration
CCNAv5 - S2: Chapter2 Basic Switching Concepts and Configuration
 
Chapter 13 : Introduction to switched networks
Chapter 13 : Introduction to switched networksChapter 13 : Introduction to switched networks
Chapter 13 : Introduction to switched networks
 
Day 20.3 frame relay
Day 20.3 frame relay Day 20.3 frame relay
Day 20.3 frame relay
 
Icnd210 s08l03
Icnd210 s08l03Icnd210 s08l03
Icnd210 s08l03
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 
05 module managing your network enviornment
05  module managing your network enviornment05  module managing your network enviornment
05 module managing your network enviornment
 
CCNA 2 Routing and Switching v5.0 Chapter 2
CCNA 2 Routing and Switching v5.0 Chapter 2CCNA 2 Routing and Switching v5.0 Chapter 2
CCNA 2 Routing and Switching v5.0 Chapter 2
 
managing your network environment
managing your network environmentmanaging your network environment
managing your network environment
 
Day 20.1 configuringframerelay
Day 20.1 configuringframerelayDay 20.1 configuringframerelay
Day 20.1 configuringframerelay
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016
 
Np unit2
Np unit2Np unit2
Np unit2
 
BitVisor Summit 11「2. BitVisor on Aarch64」
BitVisor Summit 11「2. BitVisor on Aarch64」BitVisor Summit 11「2. BitVisor on Aarch64」
BitVisor Summit 11「2. BitVisor on Aarch64」
 
Arduino programming
Arduino programmingArduino programming
Arduino programming
 

More from SysPlay eLearning Academy for You

Linux Internals Part - 3
Linux Internals Part - 3Linux Internals Part - 3
Linux Internals Part - 3
SysPlay eLearning Academy for You
 
Linux Internals Part - 2
Linux Internals Part - 2Linux Internals Part - 2
Linux Internals Part - 2
SysPlay eLearning Academy for You
 
Linux Internals Part - 1
Linux Internals Part - 1Linux Internals Part - 1
Linux Internals Part - 1
SysPlay eLearning Academy for You
 
Kernel Timing Management
Kernel Timing ManagementKernel Timing Management
Kernel Timing Management
SysPlay eLearning Academy for You
 
Understanding the BBB
Understanding the BBBUnderstanding the BBB
Understanding the BBB
SysPlay eLearning Academy for You
 
POSIX Threads
POSIX ThreadsPOSIX Threads
Linux DMA Engine
Linux DMA EngineLinux DMA Engine
Cache Management
Cache ManagementCache Management
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
Introduction to BeagleBoard-xM
Introduction to BeagleBoard-xMIntroduction to BeagleBoard-xM
Introduction to BeagleBoard-xM
SysPlay eLearning Academy for You
 
BeagleBoard-xM Booting Process
BeagleBoard-xM Booting ProcessBeagleBoard-xM Booting Process
BeagleBoard-xM Booting Process
SysPlay eLearning Academy for You
 
Linux System
Linux SystemLinux System

More from SysPlay eLearning Academy for You (12)

Linux Internals Part - 3
Linux Internals Part - 3Linux Internals Part - 3
Linux Internals Part - 3
 
Linux Internals Part - 2
Linux Internals Part - 2Linux Internals Part - 2
Linux Internals Part - 2
 
Linux Internals Part - 1
Linux Internals Part - 1Linux Internals Part - 1
Linux Internals Part - 1
 
Kernel Timing Management
Kernel Timing ManagementKernel Timing Management
Kernel Timing Management
 
Understanding the BBB
Understanding the BBBUnderstanding the BBB
Understanding the BBB
 
POSIX Threads
POSIX ThreadsPOSIX Threads
POSIX Threads
 
Linux DMA Engine
Linux DMA EngineLinux DMA Engine
Linux DMA Engine
 
Cache Management
Cache ManagementCache Management
Cache Management
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Introduction to BeagleBoard-xM
Introduction to BeagleBoard-xMIntroduction to BeagleBoard-xM
Introduction to BeagleBoard-xM
 
BeagleBoard-xM Booting Process
BeagleBoard-xM Booting ProcessBeagleBoard-xM Booting Process
BeagleBoard-xM Booting Process
 
Linux System
Linux SystemLinux System
Linux System
 

Recently uploaded

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
Techgropse Pvt.Ltd.
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 

Recently uploaded (20)

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 

I2C Drivers

  • 1. © 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Inter Integrated Circuit (I2 C) Drivers
  • 2. 2© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? I2 C Prologue I2 C Subsystem in Linux I2 C Client Driver I2 C Device Registration (Non DT and DT)
  • 3. 3© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Prologue Originally developed by Phillips (SMBus by Intel) Suitable for small slow devices I2 C is a 2-wire protocol One Serial Clock One Data Line Popular in Desktops & Embedded Systems Used for accessing EEPROMs RTCs ...
  • 4. 4© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Conditions Start Condition Master signals this condition to initiates the transfer on the bus Stop Condition Master signals this condition to stop the transfer ACK Condition Master or Slave to acknowledge the receipt of previous byte
  • 5. 5© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Transactions Master begins the communication by issuing the start condition. Sends a 7/10 bit slave address followed by read/write bit The addressed slave ACK the transfer Transmitter transmits a byte of data and receiver issues ACK on successful receipt Master issues a STOP condition to finish the transaction
  • 6. 6© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Transactions... Start Data 1 SLA + W Slave ACK Data 2 Data N Slave ACK Slave ACK Stop Master Write Slave ACK Start Data 1 SLA + W Slave ACK Repeat Start Data 1 Slave ACK SLA + R Stop Master Read Master ACK Data N Master NACK
  • 7. 7© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Character Driver Framework User Space App open(), read(), write() /dev/i2c_drv0 i2c_app.c, i2c_intr.c my_open() my_read() my_write() Char Driver Low Level I2 C Driver i2c_char.c i2c_read() i2c_write() test1.c, s1.c, s2.c.. i2c_omap.c (initialization and utility functions)
  • 8. 8© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. AM335x I2 C Registers I2C_SA_REGISTER (Slave Address Reg) I2C_CON_REGISTER (Configuration Reg) Bits for enabling the I2 C module Selecting the Fast / Standard mode of op Selecting the Master / Slave config Sending the Start / Stop conditions on the bus I2C_DATA (RX/TX Data Reg) I2C_BUF (FIFO Thresholds, DMA configuration) I2C_CNT (Bytes in I2 C data payload) I2C_IRQ_STATUS_REG
  • 9. 9© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. AM335X I2 C APIs #include “i2c_char.h” u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, int reg, u16 val) u16 wait_for_event(struct omap_i2c_dev *dev) void omap_i2c_ack_stat(struct omap_i2c_dev, u16 stat) val = omap_i2c_read_reg(dev, OMAP_I2C_BUF_REG); val |= OMAP_I2C_BUF_TXFIF omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, val);
  • 10. 10© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Writing to EEPROM For writing at EEPROM offset 0x0060 Send the start condition. Send the Slave address of EEPROM (0X50), followed by direction (Read/Write) Send the EEPROM location higher byte, followed by lower byte Send the actual data to be written Send the Stop condition START->0x50->0x00(offset High)->0x60 (offset Low)->0X95(Data)->STOP
  • 11. 11© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Reading From EEPROM Write the EEPROM offset say 0x0060 (read offset) START->0x50->0x00(offset High)->0x60 (offset Low)- >STOP Read the EEPROM data Send the start condition. Send the Slave address of EEPROM (0X50), followed by direction (Read) Read the data Send the Stop condition START->0x50->Data(RX)->Data(RX)->STOP
  • 12. 12© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Subsystem I2C subsystem provides API to implement I2 C controller driver API to implement I2 C device driver in kernel space An abstraction to implement the client drivers independent of adapter drivers
  • 13. 13© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Subsystem ... User Space Kernel Space I 2 C Device (i2c_client) I 2 C Host Controller (i2c_adapter) I 2 C Bus Hardware Space /sys, /dev User Applications I 2 C User Mode Device Driver I 2 C Core i2c-dev I 2 C Adapter (platform_driver) / Algo Driver (i2c_algorithm) Vertical: Character/SysFS I 2 C Client Driver Horizontal: I 2 C (i2c_driver)
  • 14. 14© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Subsystem Details i2c-adapter / i2-algo Controller-specific I2 C host controller / adapter Also called as the I2 C bus drivers i2c-core Hides the adapter details from the layers above By providing the generic I2 C APIs i2c-dev Provides device access in user space through /sys Enables implementation of User Mode Drivers i2c-client Driver specific to an I2 C device Implemented using i2c-core APIs
  • 15. 15© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Driver Model CPU I 2 C Controller 1 I 2 C Controller 2 I 2 C Controller 3 I 2 C Adapter 1 I 2 C Adapter 2 I 2 C Adapter 3 I 2 C Client 1 /sys/bus/i2c /sys/bus/platform /sys/bus/platform/device/xx.i2c /sys/devices/ocp.3/xx.i2c/ Platform Bus /sys/bus/i2c/devices/i2c-n I 2 C Client 2 I 2 C Client 3 I 2 C Bus /sys/bus/i2c/n-xx/i2c-n/devicen
  • 16. 16© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. SMBus Subset of I2 C Using only SMBus commands makes it compatible with both adapters Part of I2 C Core itself APIs for Device Access (Header: <linux/i2c.h>) int ioctl(smbus_fp, cmd, arg); s32 i2c_smbus_write_byte(client, val); s32 i2c_smbus_read_byte(client); s32 i2c_smbus_write_*_data(client, cmd, val); s32 i2c_smbus_read_*_data(client, cmd); client – Pointer to struct i2c_client created by the probe function
  • 17. 17© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Client Driver Typically a character driver vertical or /sys exposed But actually depends on the device category And the I2 C driver horizontal Registers with I2 C Core (in the init function) Unregisters from I2 C Core (in the cleanup function) And uses the transfer function from I2 C Core for actual data transactions int i2c_transfer (struct i2c_adapter *adap, struct i2c_msg *msgs, int num); adap is the client->adapter
  • 18. 18© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Client Driver's init & cleanup Registering to the I2 C Core using int i2c_add_driver(struct i2c_driver *); struct i2c_driver contains probe function – called on device detection remove function – called on device shutdown id_table – Table of device identifiers Unregistering from the I2 C Core using void i2c_del_driver(struct i2c_driver *); Common bare-bone of init & cleanup Just use module_i2c_driver(struct i2c_driver);
  • 19. 19© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Client Driver's Registration struct i2c_driver dummy_driver = { .driver = { .name = “dummy_client”, .owner = THIS_MODULE, }, .probe = dummy_probe, .remove = dummy_remove, .id_table = dummy_ids, } static const struct i2c_device_id dummy_ids = { { “dummy_device”, 0}, {} }; i2c_add_driver(dummy_driver);
  • 20. 20© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Adapter Driver Registering to the I2 C Core using int i2c_add_driver(struct i2c_driver *); struct i2c_driver contains probe function – called on device detection remove function – called on device shutdown id_table – Table of device identifiers Unregistering from the I2 C Core using void i2c_del_driver(struct i2c_driver *); Common bare-bone of init & cleanup Just use module_i2c_driver(struct i2c_driver);
  • 21. 21© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Checking Adapter Capabilities I2 C client driver's probe would typically check for HC capabilities Header: <linux/i2c.h> APIs u32 i2c_get_functionality (struct *i2c_adapter); int i2c_check_functionality (struct *i2c_adapter, u32 func);
  • 22. 22© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. I2 C Client Driver Examples Path: <kernel_source>/drivers/ I2 C EEPROM: AT24 misc/eeprom/at24.c I2 C Audio: Beagle Audio Codec cum Pwr Mgmt mfd/twl4030-audio.c -> mfd/twl-core.c(plat driver) I2 C RTC: DS1307 rtc/rtc-twl.c -> mfd/twl-core.c; rtc/rtc-ds1307.c Browse & Discuss any
  • 23. 23© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Registering an I2 C Client (Non DT) On non-DT platforms, the struct i2c_board_info describes how device is connected to a board Defined with I2C_BOARD_INFO helper macro Takes as argument the device name and the slave address of the device on the bus. An array of such structures is registered on per bus basis using the i2c_register_board_info during the platform initialization
  • 24. 24© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Registering an I2 C Client (Non DT).. static struct i2c_board_info my_i2c_devices [] = { { I2C_BOARD_INFO (“my_device”, 0 x1D ), . irq = 70, .platform_data = &my_data }, }; i2c_register_board_info (0, my_i2c_devices , ARRAY_SIZE ( my_i2c_devices ));
  • 25. 25© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Registering an I2 C Client (DT) In the device tree, the I2 C devices on the bus are described as children of the I2 C controller node reg property gives the I2 C slave address on the bus
  • 26. 26© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Registering an I2 C Client (DT) ... i2c@49607899 { compatible = "dummy_adap"; clock-frequency = <0x186a0>; #address-cells = <0x1>; #size-cells = <0x0>; my_dummy@0 { compatible = "dummy_device"; reg = <0x40>; }; }; Registered internally by i2c_core based on info from DTB i2c_new_device(struct i2c_adapter *, struct i2c_board_info *);
  • 27. 27© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? I2 C Prologue I2 C Subsystem in Linux I2 C Client Driver I2 C Device Registration (Non DT and DT)
  • 28. 28© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?