0

I have a system which uses module Sensors LM75 with two I2C adresses (0x48 and 0x49). I'd like to cancel one address (0x48), however I don't understand where there is its initialisation.

All changes in normal_i2c , are not relevant ....

/* Addresses scanned */
static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                    0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
2
  • Did your post get cut? It appears there's missing information about that normal_i2c (where is it from?). What have you already tried? Commented Jan 18, 2016 at 11:11
  • normal_i2c[] - it is array in lm75.c . I thought that the driver gets i2c address from this array . But it's not right. Commented Jan 18, 2016 at 12:01

1 Answer 1

3

The driver lm75.c registers itself with the kernel as a handler for ALL i2c devices with any of the 7bit addresses listed in normal_i2c array.

/* Addresses scanned */
static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
0x4d, 0x4e, 0x4f, I2C_CLIENT_END };

Next, the array is pointed to by struct lm75_driver (of type i2c_driver)

.address_list   = normal_i2c,

Also note that the class and detect members of the i2c_driver struct are initialised appropriately

.class          = I2C_CLASS_HWMON,
.detect         = lm75_detect,
  • various options for .class are listed here.
  • .detect is a function that will be called whenever a new i2c-bus or i2c-driver is being initialised.

When the driver registers with the Linux kernel, this i2c_driver struct is passed on to the Linux kernel (with the list of i2c addresses to be associated with this driver).

module_i2c_driver(lm75_driver);

At runtime, what occurs next is summarised in the following call-graph:

i2c_register_driver()

__process_new_adapter()

i2c_do_add_adapter()

i2c_detect()

lm75_detect() called using driver->detect()

The lm75_detect() function contains the device-specific logic to determine whether an i2c device detected on the current i2c bus should be handled by the current driver (in this case lm75.c) or not.

For automatic device detection, both detect and address_list must be defined. class should also be set, otherwise only devices forced with module parameters will be created.

The detect function must fill at least the name field of the i2c_board_info structure it is handed upon successful detection, and possibly also the flags field.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, I have a board with TMP75 temp sensor on a i2c bus, which is handled by lm75 driver. It's at the address 0x4a. I'm loading the driver and it's getting loaded but it is not detecting the device. In the /sys/bus/i2c/drivers/lm75/ , I see only following files/folder : bind module uevent unbind. I don't see any other entry where possibly the temp_input etc. device attributes are present. Not sure how do I debug this further..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.