Some problems with kernel module und device tree..
#1
Hello guys,

I'm developing a kernel driver for a MOST NIC and have got some problems by reading the chip configuration from device tree.

Here is the configuration:

Code:
&i2c2 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c2_pins_a>;
    status = "okay";
    
    os8104: os8104@41 {
        compatible = "smsc,os8104";
        reg = <0x41>;
        master = <0>;
        bypass = <0>;
        
        gpio_reset = <&pio 8 17>;    /* PI17 */
        gpio_int = <&pio 8 16>;        /* PI16 */
        gpio_aint = <&pio 8 19>;    /* PI19 */
        gpio_error = <&pio 8 18>;    /* PI18 */
    };
};

My NIC (os8104) is connected to i2c-2. 

And here is the corresponding code in LKM:

Code:
static int os8104_probe(struct i2c_client *client, const struct i2c_device_id *id) {
    struct device_node *dn;
    int rc;
    int master = 0, bypass = 0;
    struct os8104 *priv;

    dn = of_find_node_by_name(NULL, os8104_driver.driver.name);
    if (dn == NULL) {
        return -ENODEV;
    }

    rc = of_property_read_u32(dn, "master", &master);
    pr_err("rc = %d, master = %11d\n", rc, master);
    
    rc = of_property_read_u32(dn, "bypass", &bypass);
    pr_err("rc = %d, bypass = %11d\n", rc, bypass);

    priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);

    if (!priv) {
        return -ENOMEM;
    }

    priv->adapter = to_i2c_adapter(client->dev.parent);
    priv->client = client;
    priv->mode = val;
    
    priv->gpio_reset = of_get_named_gpio(dn, "gpio_reset", 0);
    priv->gpio_int = of_get_named_gpio(dn, "gpio_int", 0);
    priv->gpio_aint = of_get_named_gpio(dn, "gpio_aint", 0);
    priv->gpio_error = of_get_named_gpio(dn, "gpio_error", 0);
    
    return 0;
}

If I'm loading the module, the function of_find_node_by_name find my os8104 node, then I'm able to read the both properties (master and bypass). 

But, if I do an of_get_named_gpio(dn, "gpio_reset", 0), I get for each of four gpio-properties

Quote:[ 1610.330108] OF: /soc@01c00000/i2c@01c2b400/os8104@41: arguments longer than property

in dmesg.

Any ideas?

Kernel version is 4.14.39 and SBC is a BananaPRO (Allwinner A20 SoC).

Many thanks. Smile


Possibly Related Threads…
Thread Author Replies Views Last Post
  Lots of problems with pinebuds elix 1 727 07-20-2023, 06:51 PM
Last Post: elix
  Does pinephone allow you to repair your own device as easily as fairphone? unix21311 3 1,822 11-06-2022, 10:37 PM
Last Post: Harolddavies0
  LTE module for pine64 products stoiqman 1 995 10-18-2022, 12:45 PM
Last Post: poVoq
  Forum account problems diederik 3 2,617 11-19-2021, 02:44 PM
Last Post: Arwen
  E-Note Device (E-Ink, E-Paper, Project Idea) Sirius 9 8,906 08-18-2021, 08:28 AM
Last Post: biketool
  cheese camera device not found savcvet 2 2,635 07-04-2021, 05:10 AM
Last Post: Arwen
  Building Kernel App for fast GPIO nimblemotors 0 1,329 05-21-2021, 11:56 PM
Last Post: nimblemotors
  Which SBC to chose for kernel compiling roel 1 2,173 12-26-2020, 08:24 AM
Last Post: lanefu
Question Micro computer module Computer semi-expert 7 8,148 09-29-2020, 04:52 PM
Last Post: tllim
  IRC Problems? Hiraghm 2 3,735 08-24-2020, 05:45 AM
Last Post: pfeerick

Forum Jump:


Users browsing this thread: 1 Guest(s)