Skip to content

Commit de270e5

Browse files
committed
[DM/I2C] Update I2C for DM
1. Add get id match data API. 2. Set I2C device name default before adding to bus. 3. Add Kconfig import for DM. Signed-off-by: GuEe-GUI <[email protected]>
1 parent 2fb53c8 commit de270e5

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

components/drivers/i2c/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
config RT_USING_I2C
1+
menuconfig RT_USING_I2C
22
bool "Using I2C device drivers"
33
default n
44

@@ -241,3 +241,7 @@ if RT_USING_I2C
241241
endif
242242
endif
243243
endif
244+
245+
if RT_USING_DM && RT_USING_I2C
246+
osource "$(SOC_DM_I2C_DIR)/Kconfig"
247+
endif

components/drivers/i2c/dev_i2c_bus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ void i2c_bus_scan_clients(struct rt_i2c_bus_device *bus)
6161
client->bus = bus;
6262
client->client_addr = client_addr;
6363

64+
rt_dm_dev_set_name(&client->parent, "%s", client->name);
65+
6466
rt_i2c_device_register(client);
6567

6668
if (i2c_client_np != child_np)

components/drivers/include/drivers/dev_i2c.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ rt_err_t rt_i2c_driver_register(struct rt_i2c_driver *driver);
286286
rt_err_t rt_i2c_device_register(struct rt_i2c_client *client);
287287

288288
#define RT_I2C_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, i2c, BUILIN)
289+
290+
rt_inline const void *rt_i2c_client_id_data(struct rt_i2c_client *client)
291+
{
292+
return client->id ? client->id->data : (client->ofw_id ? client->ofw_id->data : RT_NULL);
293+
}
289294
#endif /* RT_USING_DM */
290295

291296
/**

0 commit comments

Comments
 (0)