Skip to contentSkip to conversation

status of i2c-cpm and ds2482

DISCUSSION Baurzhan Ismagulov 3 participants 12 messages Jan 8, 2010 – Jan 9, 2010 8 messages not in the archive I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Hello,

I have a 2.6.25.7 kernel working on my MPC885 board with i2c-cpm and ds2482. I'm currently rebasing the board changes on a newer kernel. So far I could get to 2.6.27.25 (with i2c-cpm and ds2482 from linux-2.6 git). Other parts of 2.6.27.25 work better with the board, so I'd like to get the application (reportedly using the /sys/devices/w1_bus_master1/* interface) working and have a couple of questions.

What is the current state of i2c-cpm and ds2482 in 2.6 or 2.6.27 gits? If I correctly understand the commit messages, those are maintained. There are boot messages about both. Creating /dev/i2c-0 and reading from it result in appropriate debug messages. However, /sys/devices/w1_bus_master1 is not created; the path described in
http://marc.info/?l=linux-i2c&m=125365009130579&w=2 does not exist. What is the fastest way to get the application running on 2.6.27.25?

Thanks in advance,
Baurzhan.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi Baurzhan,

Quoted 5 lines

There are boot messages about both. Creating /dev/i2c-0 and reading from it result in appropriate debug messages. However, /sys/devices/w1_bus_master1 is not created; the path described in
http://marc.info/?l=linux-i2c&m=125365009130579&w=2 does not exist. What is the fastest way to get the application running on 2.6.27.25?

What does your dts look like? Is the ds2482 present in the dts?

Thanks,
Jochen

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hello Jochen,

Quoted 7 lines · Jochen Friedrich
Quoted 5 lines

There are boot messages about both. Creating /dev/i2c-0 and reading from it result in appropriate debug messages. However, /sys/devices/w1_bus_master1 is not created; the path described in
http://marc.info/?l=linux-i2c&m=125365009130579&w=2 does not exist. What is the fastest way to get the application running on 2.6.27.25?

What does your dts look like? Is the ds2482 present in the dts?

Oh, that's an interesting point. No, it isn't present, only i2c. How did it work in 2.6.25.7? I'd also appreciate pointers about that, if there are any.

Currently I'm trying to understand why the new i2c infrastructure doesn't call ds2482_probe, which creates the w1_bus_master1 directory. Other ideas also welcome.

Gruß,
Baurzhan.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi Baurzhan,

Quoted 3 lines

Oh, that's an interesting point. No, it isn't present, only i2c. How did it work in 2.6.25.7? I'd also appreciate pointers about that, if there are any.

It was probably probed by some userspace tool. This has been turned off as probing i2c might be problematic on Soc boards. See:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0a346dacee18ff69f6162d9860d723a058f47321

You could try to add the property "linux,i2c-class=1" to the i2c controller in your dts to see if this commit is the cause of difference.

Quoted 3 lines

Currently I'm trying to understand why the new i2c infrastructure doesn't call ds2482_probe, which creates the w1_bus_master1 directory. Other ideas also welcome.

You should definitely add your ds2482 to the device tree so it is auto loaded by the i2c subsystem.

Thanks,
Jochen

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 3 lines · Jochen Friedrich
Quoted 1 line

How did it work in 2.6.25.7?

It was probably probed by some userspace tool.

Nope, it worked directly after booting. The initialization sequence looked like this:

w1_add_master_device
ds2482_attach_adapter
i2c_register_driver
sensors_ds2482_init
kernel_init
kernel_thread

Quoted 6 lines

This has been turned off as probing i2c might be problematic on Soc boards. See:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0a346dacee18ff69f6162d9860d723a058f47321

You could try to add the property "linux,i2c-class=1" to the i2c controller in your dts to see if this commit is the cause of difference.

I've added "linux,i2c-class = <1>;" to i2c@860; this has set i2c-cpm's class to I2C_CLASS_HWMON. You are probably right in that the problem seems to be partly related to that.

That said, the default class of i2c-cpm is I2C_CLASS_HWMON | I2C_CLASS_SPD, whereas the one of ds2482 is not set and thus zero (I'm using 2.6.27.25), so if (!(adapter->class & driver->class)) in i2c_detect goes to exit_free. So yesterday I had to set ds2482's class to I2C_CLASS_SPD since the classes have to match.

However, it still goes to exit_free immediately after that since ds2482 doesn't provide I2C_FUNC_SMBUS_QUICK. IIUC, drivers are not required to provide that, so I'm still looking why cpm_i2c_probe and ds2482_probe don't get called.

Quoted 2 lines

You should definitely add your ds2482 to the device tree so it is auto loaded by the i2c subsystem.

You mean, in dts? Do you have a template for that? I could look up the necessary values in the working 2.6.25.7 kernel if I knew which ones I need. Which routine reads it and calls probe?

Gruß,
Baurzhan.

#9 lore raw
In reply to a message not in the archive
Quoted 9 lines · Baurzhan Ismagulov

Hello Jochen,

Quoted 6 lines · Jochen Friedrich
Quoted 5 lines

There are boot messages about both. Creating /dev/i2c-0 and reading from it result in appropriate debug messages. However, /sys/devices/w1_bus_master1 is not created; the path described in
http://marc.info/?l=linux-i2c&m=125365009130579&w=2 does not exist. What is the fastest way to get the application running on 2.6.27.25?

Quoted 5 lines
Quoted 1 line

What does your dts look like? Is the ds2482 present in the dts?

Oh, that's an interesting point. No, it isn't present, only i2c. How did it work in 2.6.25.7? I'd also appreciate pointers about that, if there are any.

You probably want to take a look at these 2 patches of mine which were applied to the ds2482 driver:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=61c91f7ded640bb2b340cc89d9ca3a3ca0229c74
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=0314b020c49c1d6cd182d2b89775bfa6686660db

The first one went in 2.6.27, the second in 2.6.32.

Quoted 3 lines

Currently I'm trying to understand why the new i2c infrastructure doesn't call ds2482_probe, which creates the w1_bus_master1 directory. Other ideas also welcome.

Before 2.6.27, the ds2482 driver was a so-called "legacy i2c driver" probing buses randomly in search of supported chips. Since 2.6.27 is is a so-called "new-style i2c driver" which only attaches to the devices when told to. So what you observe is the expected behavior. It is much safer that way.

For an overview of how an I2C device can be declared, see:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/i2c/instantiating-devices

One method not described in this document is listing the device in a dts. It should probably be added, unfortunately I don't know enough about this myself to do it. Any volunteer?

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

Hello Jean,

Quoted 4 lines · Jean Delvare

You probably want to take a look at these 2 patches of mine which were applied to the ds2482 driver:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=61c91f7ded640bb2b340cc89d9ca3a3ca0229c74
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=0314b020c49c1d6cd182d2b89775bfa6686660db

Yes, I studied them yesterday in detail :) . The docs in i2c are also useful to get the big picture, thank you. That said, I'm currently stuck how to make the infrastructure probe ds2482.

Quoted 5 lines

Before 2.6.27, the ds2482 driver was a so-called "legacy i2c driver" probing buses randomly in search of supported chips. Since 2.6.27 is is a so-called "new-style i2c driver" which only attaches to the devices when told to. So what you observe is the expected behavior. It is much safer that way.

Yes, this is clear from your docs.

Quoted 2 lines

For an overview of how an I2C device can be declared, see:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/i2c/instantiating-devices

As I wrote yesterday, I did try Method 4. However, /sys/bus/i2c/devices/i2c-0 doesn't exist.

There is also ds2482_detect in ds2482.c of 2.6.27.25 (Method 3); still cannot see /sys/devices/w1_bus_master1.

What is the problem there? Should I update some infrastructure files from 2.6 git? For now, I can't use newer kernels since they either hang or run very slowly ("time id" taking real 32s) on my board.

Quoted 3 lines

One method not described in this document is listing the device in a dts. It should probably be added, unfortunately I don't know enough about this myself to do it. Any volunteer?

I would gladly contribute that as soon as I learn how to do that :) .

Thanks in advance,
Baurzhan.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Hi Baurzhan,

Quoted 5 lines
Quoted 3 lines

One method not described in this document is listing the device in a dts. It should probably be added, unfortunately I don't know enough about this myself to do it. Any volunteer?

I would gladly contribute that as soon as I learn how to do that :) .

just add your ds2482 as child node to the i2c controller like this:

	I2C0: i2c@860 {
		compatible = "fsl,mpc823-i2c",
			     "fsl,cpm1-i2c";
		reg = <0x860 0x20 0x3c80 0x30>;
		interrupts = <16>;
		interrupt-parent = <&CPM_PIC>;
		fsl,cpm-command = <0x10>;
		bus-frequency = <100000>;

		w1@aa {
			reg = <0xaa>;
			compatible = "dallas,ds2482";
		};
	};

Of course you'll have to replace "aa" with the real i2c address of the device.

Thanks,
Jochen

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw
Quoted 1 line · Jochen Friedrich
	I2C0: i2c@860 {

...

Quoted 5 lines
		w1@aa {
			reg = <0xaa>;
			compatible = "dallas,ds2482";
		};
	};

This worked, thanks much Jochen and Jean!

I had to use "reg = <18>;", it didn't build with "0x".

FWIW, I've also tried restoring 0x18 in normal_i2c in ds2482.c, and i2c-core complained about quick not being supported. Where can I read about what it is? Why is it now required, whereas this worked in 2.6.25.7?

With kind regards,
Baurzhan.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#17 lore raw

Hi Baurzhan,

Quoted 9 lines · Baurzhan Ismagulov
Quoted 1 line · Jochen Friedrich
	I2C0: i2c@860 {

...

Quoted 5 lines
		w1@aa {
			reg = <0xaa>;
			compatible = "dallas,ds2482";
		};
	};
Quoted 6 lines

This worked, thanks much Jochen and Jean!

I had to use "reg = <18>;", it didn't build with "0x".

FWIW, I've also tried restoring 0x18 in normal_i2c in ds2482.c, and i2c-core complained about quick not being supported.

Restoring? 0x18 has never been in ds2482's normal_i2c list.

Quoted 1 line

Where can I read about what it is?

As I2C doesn't offer any standard way to detect device presence at a given address, we (ab)use the SMBus "Quick command" (0-byte message) for this purpose. Not all adapters support this type of transaction.

Quoted 1 line

Why is it now required, whereas this worked in 2.6.25.7?

The i2c-cpm driver was not present in kernel 2.6.25.7, so you must have been using an out-of-tree driver. Maybe that driver had (possibly fake) support for the SMBus quick command.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/wishlist.html
#18 lore raw
In reply to a message not in the archive

Hi Baurzhan,

Quoted 5 lines
Quoted 3 lines

One method not described in this document is listing the device in a dts. It should probably be added, unfortunately I don't know enough about this myself to do it. Any volunteer?

I would gladly contribute that as soon as I learn how to do that :) .

Some documentation about this can be found in the kernel source at

Documentation/powerpc/dts-bindings/fsl/cpm_qe/cpm/i2c.txt

Thanks,
Jochen

#19 lore raw
In reply to a message not in the archive
Quoted 6 lines · Baurzhan Ismagulov
Quoted 2 lines · Jean Delvare

For an overview of how an I2C device can be declared, see:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/i2c/instantiating-devices

As I wrote yesterday, I did try Method 4. However, /sys/bus/i2c/devices/i2c-0 doesn't exist.

/sys/bus/i2c/devices/i2c-* is new in kernel 2.6.32. For older kernels, look in /sys/class/i2c-adapter. That being said, method 4 is new in kernel 2.6.31 anyway, so it isn't what you want.

Quoted 2 lines

There is also ds2482_detect in ds2482.c of 2.6.27.25 (Method 3); still cannot see /sys/devices/w1_bus_master1.

As I recall, this isn't a real detect function, because the list of addresses to probe by default is empty. For the detect function to be called, you must provide extra module parameters (e.g. probe or force).

Quoted 3 lines

What is the problem there? Should I update some infrastructure files from 2.6 git? For now, I can't use newer kernels since they either hang or run very slowly ("time id" taking real 32s) on my board.

You don't have to update anything, other than your dts file. Until your dts file lists the ds2482 device, you must load the ds2482 driver with the right parameter.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/wishlist.html