Hi,
I have followed the [Device Registration] / [Using Main Platform Device Tree File] in the [Sensor Driver Programming Guide] to the point, but the probe() never happens:
This is the dtsi for the “camera expander” included like [Using Main Platform Device Tree File] says:
/ {
i2c@3180000 {
j20_6@20 {
compatible = “nvidia,j20”;
/* I2C device address */
reg = <0x20>;
status = “okay”;
//reset-gpios = <&tegra_main_gpio CAM0_PWDN GPIO_ACTIVE_HIGH>;
};
};
};
And this is the j20.c code, works good on Jetpack3.2 /tx2 :
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/i2c-dev.h>
#include <linux/fs.h>
#include <media/camera_common.h>
#include <media/soc_camera.h>
#include <dt-bindings/gpio/tegra-gpio.h>
static struct of_device_id j20_of_match = {
{ .compatible = “nvidia,j20”, },
{ },
};
MODULE_DEVICE_TABLE(of, j20_of_match);
static int j20_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device_node *np = client->dev.of_node;
const struct of_device_id *match;
int gpio;
dev_info(&client->dev, “[J20] Driver: Function: %s.\n”, func);
match = of_match_device(j20_of_match, &client->dev);
if (!match) {
dev_info(&client->dev, “Failed to find matching dt id\n”);
return -1;
}
gpio = of_get_named_gpio(np, “reset-gpios”, 0);
if (gpio < 0) {
dev_err(&client->dev, “reset gpios not in DT\n”);
}
gpio_set_value(gpio, 1);
dev_info(&client->dev,“[J20]: Enabling GPIO: %i.\n”, gpio);
if (i2c_smbus_write_byte_data(client, 6, 0x3e) < 0)
dev_err(&client->dev, “Failed writing to reg: %d val %d\n”, 6, 0x3e);
if (i2c_smbus_write_byte_data(client, 7, 0x33) < 0)
dev_err(&client->dev, “Failed writing to reg: %d val %d\n”, 7, 0x33);
if (i2c_smbus_write_byte_data(client, 2, 0xfe) < 0)
dev_err(&client->dev, “Failed writing to reg: %d val %d\n”, 2, 0xfe);
if (i2c_smbus_write_byte_data(client, 3, 0xff) < 0)
dev_err(&client->dev, “Failed writing to reg: %d val %d\n”, 3, 0xff);
dev_info(&client->dev,“[J20]: Writing setup configuration .\n”);
return 0;
}
static int
j20_remove(struct i2c_client *client)
{
return 0;
}
static const struct i2c_device_id j20_id = {
{ “j20”, 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, j20_id);
static struct i2c_driver j20_i2c_driver = {
.driver = {
.name = “j20”,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(j20_of_match),
},
.probe = j20_probe,
.remove = j20_remove,
.id_table = j20_id,
};
module_i2c_driver(j20_i2c_driver);
The new dtb is flashed from the host with “sudo ./flash.sh -r -k kernel-dtb jetson-xavier mmcblk0p1” , and after a reboot and a dtb decompile i find back the j20 entries in it, so the flash went well…
i can also modprobe j20…