Re: Regarding to force bus id for channels of pca954x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/6/2015 9:35 AM, os user wrote:
Hi there,

For some reasons, we need to assign bus id for the channels of I2c mux pca9548.

From the code, it seems we can use "adap_id" of

struct pca954x_platform_mode {
   int             adap_id;
   unsigned int    deselect_on_exit:1;
   unsigned int    class;
};

But my questions is, can we assign bus id through device tree and modprobe?
I have been meaning to submit a patch for this to the documentation. I'll get to it soon. See attachment on how to assign i2c bus numbers from the DT.
-Bob

Thanks.

On Thu, May 7, 2015 at 12:33 AM, os user <gnusercn@xxxxxxxxx> wrote:
Hi there,

For some reasons, we need to assign bus id for the channels of I2c mux
pca9548.

 From the code, it seems we can use "adap_id" of

struct pca954x_platform_mode {
   int             adap_id;
   unsigned int    deselect_on_exit:1;
   unsigned int    class;
};

But my questions is, can we assign bus id through device tree and modprobe?

Thanks.

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Common i2c bus multiplexer/switch properties.

An i2c bus multiplexer/switch will have several child busses that are
numbered uniquely in a device dependent manner.  The nodes for an i2c bus
multiplexer/switch will have one child node for each child
bus.

Required properties:
- #address-cells = <1>;
- #size-cells = <0>;

Required properties for child nodes:
- #address-cells = <1>;
- #size-cells = <0>;
- reg : The sub-bus number.

Optional properties for child nodes:
- Other properties specific to the multiplexer/switch hardware.
- Child nodes conforming to i2c bus binding


Example :

	/*
	   An NXP pca9548 8 channel I2C multiplexer at address 0x70
	   with two NXP pca8574 GPIO expanders attached, one each to
	   ports 3 and 4.
	 */

	mux@70 {
		compatible = "nxp,pca9548";
		reg = <0x70>;
		#address-cells = <1>;
		#size-cells = <0>;

		i2c@3 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <3>;

			gpio1: gpio@38 {
				compatible = "nxp,pca8574";
				reg = <0x38>;
				#gpio-cells = <2>;
				gpio-controller;
			};
		};
		i2c@4 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <4>;

			gpio2: gpio@38 {
				compatible = "nxp,pca8574";
				reg = <0x38>;
				#gpio-cells = <2>;
				gpio-controller;
			};
		};
	};
	
The I2C subsystem will assign names to the child busses dynamically in
the form i2c-n; where 'n' is an incrementing number starting with the 
number following the previously highest allocated bus number.

Alliases may be used to assign static child bus names. The alias name 
must be of the form i2cnn where nn is numeric. The numeric part (nn) is
used to set the bus number.

Example :

/ {
	aliases {
		i2c10 = &im0;
		i2c11 = &im1;
		i2c12 = &im2;
		i2c13 = &im3;
		i2c14 = &im4;
		i2c15 = &im5;
		i2c16 = &im6;
		i2c17 = &im7;
	};
};
...
	i2cmux@70 {
	 	compatible = "nxp,pca9548";
	 	#address-cells = <1>;
	 	#size-cells = <0>;
	 	reg = <0x70>;

 im0:	i2cm@0 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0>;
		};
 im1:	i2cm@1 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <1>;
		};
 im2:	i2cm@2 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <2>;
		};
 im3:	i2cm@3 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <3>;
		};
 im4:	i2cm@4 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <4>;
		};
 im5:	i2cm@5 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <5>;
		};
 im6:	i2cm@6 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <6>;
		};
 im7:	i2cm@7 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <7>;
		};
	 };

The above file segment causes the child i2c busses to be named
i2c-10 through i2c-17.

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux