1c66ec88fSEmmanuel VadotCE4100 I2C 2c66ec88fSEmmanuel Vadot---------- 3c66ec88fSEmmanuel Vadot 4c66ec88fSEmmanuel VadotCE4100 has one PCI device which is described as the I2C-Controller. This 5c66ec88fSEmmanuel VadotPCI device has three PCI-bars, each bar contains a complete I2C 6c66ec88fSEmmanuel Vadotcontroller. So we have a total of three independent I2C-Controllers 7c66ec88fSEmmanuel Vadotwhich share only an interrupt line. 8c66ec88fSEmmanuel VadotThe driver is probed via the PCI-ID and is gathering the information of 9c66ec88fSEmmanuel Vadotattached devices from the devices tree. 10c66ec88fSEmmanuel VadotGrant Likely recommended to use the ranges property to map the PCI-Bar 11c66ec88fSEmmanuel Vadotnumber to its physical address and to use this to find the child nodes 12c66ec88fSEmmanuel Vadotof the specific I2C controller. This were his exact words: 13c66ec88fSEmmanuel Vadot 14c66ec88fSEmmanuel Vadot Here's where the magic happens. Each entry in 15c66ec88fSEmmanuel Vadot ranges describes how the parent pci address space 16c66ec88fSEmmanuel Vadot (middle group of 3) is translated to the local 17c66ec88fSEmmanuel Vadot address space (first group of 2) and the size of 18c66ec88fSEmmanuel Vadot each range (last cell). In this particular case, 19c66ec88fSEmmanuel Vadot the first cell of the local address is chosen to be 20c66ec88fSEmmanuel Vadot 1:1 mapped to the BARs, and the second is the 21c66ec88fSEmmanuel Vadot offset from be base of the BAR (which would be 22c66ec88fSEmmanuel Vadot non-zero if you had 2 or more devices mapped off 23c66ec88fSEmmanuel Vadot the same BAR) 24c66ec88fSEmmanuel Vadot 25c66ec88fSEmmanuel Vadot ranges allows the address mapping to be described 26c66ec88fSEmmanuel Vadot in a way that the OS can interpret without 27c66ec88fSEmmanuel Vadot requiring custom device driver code. 28c66ec88fSEmmanuel Vadot 29c66ec88fSEmmanuel VadotThis is an example which is used on FalconFalls: 30c66ec88fSEmmanuel Vadot------------------------------------------------ 31c66ec88fSEmmanuel Vadot i2c-controller@b,2 { 32c66ec88fSEmmanuel Vadot #address-cells = <2>; 33c66ec88fSEmmanuel Vadot #size-cells = <1>; 34c66ec88fSEmmanuel Vadot compatible = "pci8086,2e68.2", 35c66ec88fSEmmanuel Vadot "pci8086,2e68", 36c66ec88fSEmmanuel Vadot "pciclass,ff0000", 37c66ec88fSEmmanuel Vadot "pciclass,ff00"; 38c66ec88fSEmmanuel Vadot 39c66ec88fSEmmanuel Vadot reg = <0x15a00 0x0 0x0 0x0 0x0>; 40c66ec88fSEmmanuel Vadot interrupts = <16 1>; 41c66ec88fSEmmanuel Vadot 42c66ec88fSEmmanuel Vadot /* as described by Grant, the first number in the group of 43c66ec88fSEmmanuel Vadot * three is the bar number followed by the 64bit bar address 44c66ec88fSEmmanuel Vadot * followed by size of the mapping. The bar address 45c66ec88fSEmmanuel Vadot * requires also a valid translation in parents ranges 46c66ec88fSEmmanuel Vadot * property. 47c66ec88fSEmmanuel Vadot */ 48c66ec88fSEmmanuel Vadot ranges = <0 0 0x02000000 0 0xdffe0500 0x100 49c66ec88fSEmmanuel Vadot 1 0 0x02000000 0 0xdffe0600 0x100 50c66ec88fSEmmanuel Vadot 2 0 0x02000000 0 0xdffe0700 0x100>; 51c66ec88fSEmmanuel Vadot 52c66ec88fSEmmanuel Vadot i2c@0 { 53c66ec88fSEmmanuel Vadot #address-cells = <1>; 54c66ec88fSEmmanuel Vadot #size-cells = <0>; 55c66ec88fSEmmanuel Vadot compatible = "intel,ce4100-i2c-controller"; 56c66ec88fSEmmanuel Vadot 57c66ec88fSEmmanuel Vadot /* The first number in the reg property is the 58c66ec88fSEmmanuel Vadot * number of the bar 59c66ec88fSEmmanuel Vadot */ 60c66ec88fSEmmanuel Vadot reg = <0 0 0x100>; 61c66ec88fSEmmanuel Vadot 62c66ec88fSEmmanuel Vadot /* This I2C controller has no devices */ 63c66ec88fSEmmanuel Vadot }; 64c66ec88fSEmmanuel Vadot 65c66ec88fSEmmanuel Vadot i2c@1 { 66c66ec88fSEmmanuel Vadot #address-cells = <1>; 67c66ec88fSEmmanuel Vadot #size-cells = <0>; 68c66ec88fSEmmanuel Vadot compatible = "intel,ce4100-i2c-controller"; 69c66ec88fSEmmanuel Vadot reg = <1 0 0x100>; 70c66ec88fSEmmanuel Vadot 71c66ec88fSEmmanuel Vadot /* This I2C controller has one gpio controller */ 72c66ec88fSEmmanuel Vadot gpio@26 { 73c66ec88fSEmmanuel Vadot #gpio-cells = <2>; 74*5956d97fSEmmanuel Vadot compatible = "nxp,pcf8575"; 75c66ec88fSEmmanuel Vadot reg = <0x26>; 76c66ec88fSEmmanuel Vadot gpio-controller; 77c66ec88fSEmmanuel Vadot }; 78c66ec88fSEmmanuel Vadot }; 79c66ec88fSEmmanuel Vadot 80c66ec88fSEmmanuel Vadot i2c@2 { 81c66ec88fSEmmanuel Vadot #address-cells = <1>; 82c66ec88fSEmmanuel Vadot #size-cells = <0>; 83c66ec88fSEmmanuel Vadot compatible = "intel,ce4100-i2c-controller"; 84c66ec88fSEmmanuel Vadot reg = <2 0 0x100>; 85c66ec88fSEmmanuel Vadot 86c66ec88fSEmmanuel Vadot gpio@26 { 87c66ec88fSEmmanuel Vadot #gpio-cells = <2>; 88*5956d97fSEmmanuel Vadot compatible = "nxp,pcf8575"; 89c66ec88fSEmmanuel Vadot reg = <0x26>; 90c66ec88fSEmmanuel Vadot gpio-controller; 91c66ec88fSEmmanuel Vadot }; 92c66ec88fSEmmanuel Vadot }; 93c66ec88fSEmmanuel Vadot }; 94