All of lore.kernel.org
 help / color / mirror / Atom feed
* I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ?
@ 2016-03-13 12:43 sergk sergk2mail
  2016-03-14 12:21 ` Jarkko Nikula
  0 siblings, 1 reply; 6+ messages in thread
From: sergk sergk2mail @ 2016-03-13 12:43 UTC (permalink / raw)
  To: linux-i2c

Hi All,
Please help to correct create i2c client with ACPI support for device
(touchscreen) on i2c on vanilla 4.4.2 kernel x86_64 Baytrail,
disrtibutive = Arch.
========================================================
According kernel Documentation I have created such skeleton:


#define DEVICE_NAME  "testme"

static const struct acpi_device_id icn_ts_acpi_match[] = {
    { "CHPN0001", 0 },
    { "PNP05C0", 0 },
    { },
};
MODULE_DEVICE_TABLE(acpi, icn_ts_acpi_match);


static int ts_probe(struct i2c_client *client, const struct i2c_device_id *id){
    printk("Hello from %s",__func__);

    printk(&client->dev, "%s: got a device named %s at address 0x%x,
IRQ %d, flags 0x%x\n", __func__, client->name, client->addr,
client->irq, client->flags);

return 0;
}

static struct i2c_driver icn_ts_driver = {
    .probe = ts_probe,
    .remove = ts_remove,
    .id_table = ts_i2c_id,
    .driver = {
        .name = DEVICE_NAME,
        .owner = THIS_MODULE,
        .acpi_match_table = ACPI_PTR(icn_ts_acpi_match),

    },
};

static const struct i2c_device_id ts_i2c_id[] = {
    { DEVICE_NAME, 0 },
    { }
};
MODULE_DEVICE_TABLE(i2c, gsl_ts_i2c_id);


module_i2c_driver(icn_ts_driver);

===============================================


As result - nothing until I create i2c device with the name testme. I
am using user space way from kernel doc: echo testme 0x30 >
/sys/bus/i2c/devices/i2c-3/new_device.

ONLY AFTER this (Creating i2c device) I receive output from .probe function.
And as result I do NOT receive NOTHING ACPI related because i2c device
was created manually and all information is taken from my manual
created dev (bus address and bus number), no irq - nothing while DSDT
HAS THIS INFO!


>                        I2cSerialBus (0x0030, ControllerInitiated, 0x00061A80,
>                             AddressingMode7Bit, "\\_SB.I2C4",
>                             0x00, ResourceConsumer, ,
>                             )
>                         Interrupt (ResourceConsumer, Level,
> ActiveHigh, Exclusive, ,, )
>                         {
>                             0x00000044,
>                         }
>                         GpioIo (Exclusive, PullDefault, 0x0000,
> 0x0000, IoRestrictionOutputOnly,
>                             "\\_SB.GPO1", 0x00, ResourceConsumer, ,
>                             )
>                             {   // Pin list
>                                 0x001A
>                             }


MAIN QUESTIONS:

1) What is wrong with i2c client driver code? Why it is NOT obtain
info from ACPI DSD table?

2) In which way should be created i2c dev while registering i2c acpi
driver? Who\where\what and how should create this i2c device?


3) how to obtain info from ACPI DSD table?
In kernel doc there is a few lines but there is no enough detail explanation:


"This means that when ACPI_HANDLE(dev) returns non-NULL the device was
enumerated from ACPI namespace. This handle can be used to extract other
device-specific configuration."

PS: In Android I have seen some technic when 1st is created platform
driver, then via ACPI handle it gather all DSDT info.

Could some one example this with code (skeleton) and how then move
from platfrom driver to i2c client driver?

Regards,
                 Serge Kolotylo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ?
  2016-03-13 12:43 I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ? sergk sergk2mail
@ 2016-03-14 12:21 ` Jarkko Nikula
  2016-03-15 22:26   ` sergk sergk2mail
  0 siblings, 1 reply; 6+ messages in thread
From: Jarkko Nikula @ 2016-03-14 12:21 UTC (permalink / raw)
  To: sergk sergk2mail, linux-i2c

Hi

On 03/13/2016 02:43 PM, sergk sergk2mail wrote:
> Hi All,
> Please help to correct create i2c client with ACPI support for device
> (touchscreen) on i2c on vanilla 4.4.2 kernel x86_64 Baytrail,
> disrtibutive = Arch.
> ========================================================
> According kernel Documentation I have created such skeleton:
>
>
> #define DEVICE_NAME  "testme"
>
> static const struct acpi_device_id icn_ts_acpi_match[] = {
>      { "CHPN0001", 0 },
>      { "PNP05C0", 0 },
>      { },
> };

Touchscreen and PNPxxxx: can it be i2c-hid compatible touchscreen?

Those typically have vendor specific ACPI _HID but device is matched 
using ACPI PNP compatible ID (_CID) "PNP0C50" or "ACPI0C50". See 
drivers/hid/i2c-hid/i2c-hid.c.

Just thinking if you have device with _CID "PNP0C50" and either device 
is matched before your driver with i2c-hid driver or your driver doesn't 
probe because "PNP05C0" != "PNP0C50".

> MAIN QUESTIONS:
>
> 1) What is wrong with i2c client driver code? Why it is NOT obtain
> info from ACPI DSD table?
>
Your example looks ok. Another what comes to my mind is the device 
actually present. Sometimes DSDT tables may specify multiple alternative 
devices but only one being actually connected. You could check that by 
reading the device status which reads 15 if the device is present.

cat /sys/bus/acpi/devices/ACPI01234/status
15

> 2) In which way should be created i2c dev while registering i2c acpi
> driver? Who\where\what and how should create this i2c device?
>
i2c-core registers the i2c devices connected to certain bus when adapter 
device for that bus is registered in i2c-core.c: i2c_register_adapter().

-- 
Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ?
  2016-03-14 12:21 ` Jarkko Nikula
@ 2016-03-15 22:26   ` sergk sergk2mail
  2016-03-15 23:02     ` sergk sergk2mail
  2016-03-15 23:12     ` sergk sergk2mail
  0 siblings, 2 replies; 6+ messages in thread
From: sergk sergk2mail @ 2016-03-15 22:26 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-i2c

Hi Jarko,
Exploring sysfs shows:

ls -l /sys/bus/acpi/devices/CHPN0001:00
lrwxrwxrwx 1 root root 0 Mar 15 22:08
/sys/bus/acpi/devices/CHPN0001:00 ->
../../../devices/LNXSYSTM:00/LNXSYBUS:00/80860F41:03/CHPN0001:00
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/status
0

status is 0 - what does this mean? It is detected via ACPI but not present?
What does "LNXSYBUS:00/80860F41:03"  means?  Does it mean i2c-3, 0x41
?  80860F41:03 == ?

also inside its subfolders I do not see nothing useful:

cat /sys/bus/acpi/devices/CHPN0001:00/adr
0x00000000
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/hid
CHPN0001
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/modalias
acpi:CHPN0001:PNP0C50:
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/path
\_SB_.I2C4.TCS5
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/uevent
MODALIAS=acpi:CHPN0001:PNP0C50:
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/runtime_usage
0
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/control
auto
root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/runtime_enabled
disabled

So the question is the same - how to obtain via acpi in mentioned
above code i2cbus, bus addr and irq for this touch?

Regards,
                 Serge Kolotylo.

On Mon, Mar 14, 2016 at 12:21 PM, Jarkko Nikula
<jarkko.nikula@linux.intel.com> wrote:
> Hi
>
> On 03/13/2016 02:43 PM, sergk sergk2mail wrote:
>>
>> Hi All,
>> Please help to correct create i2c client with ACPI support for device
>> (touchscreen) on i2c on vanilla 4.4.2 kernel x86_64 Baytrail,
>> disrtibutive = Arch.
>> ========================================================
>> According kernel Documentation I have created such skeleton:
>>
>>
>> #define DEVICE_NAME  "testme"
>>
>> static const struct acpi_device_id icn_ts_acpi_match[] = {
>>      { "CHPN0001", 0 },
>>      { "PNP05C0", 0 },
>>      { },
>> };
>
>
> Touchscreen and PNPxxxx: can it be i2c-hid compatible touchscreen?
>
> Those typically have vendor specific ACPI _HID but device is matched using
> ACPI PNP compatible ID (_CID) "PNP0C50" or "ACPI0C50". See
> drivers/hid/i2c-hid/i2c-hid.c.
>
> Just thinking if you have device with _CID "PNP0C50" and either device is
> matched before your driver with i2c-hid driver or your driver doesn't probe
> because "PNP05C0" != "PNP0C50".
>
>> MAIN QUESTIONS:
>>
>> 1) What is wrong with i2c client driver code? Why it is NOT obtain
>> info from ACPI DSD table?
>>
> Your example looks ok. Another what comes to my mind is the device actually
> present. Sometimes DSDT tables may specify multiple alternative devices but
> only one being actually connected. You could check that by reading the
> device status which reads 15 if the device is present.
>
> cat /sys/bus/acpi/devices/ACPI01234/status
> 15
>
>> 2) In which way should be created i2c dev while registering i2c acpi
>> driver? Who\where\what and how should create this i2c device?
>>
> i2c-core registers the i2c devices connected to certain bus when adapter
> device for that bus is registered in i2c-core.c: i2c_register_adapter().
>
> --
> Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ?
  2016-03-15 22:26   ` sergk sergk2mail
@ 2016-03-15 23:02     ` sergk sergk2mail
  2016-03-15 23:12     ` sergk sergk2mail
  1 sibling, 0 replies; 6+ messages in thread
From: sergk sergk2mail @ 2016-03-15 23:02 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-i2c

In addition here is   ACPI DSDT for touch:

          Device (TCS5)
            {
                Name (_ADR, Zero)  // _ADR: Address
                Name (_HID, "CHPN0001")  // _HID: Hardware ID
                Name (_CID, "PNP0C50" /* HID Protocol Device (I2C bus)
*/)  // _CID: Compatible ID
                Name (_S0W, Zero)  // _S0W: S0 Device Wake State
                Name (_DEP, Package (0x02)  // _DEP: Dependencies
                {
                    GPO1,
                    I2C5
                })
                Method (_PS3, 0, Serialized)  // _PS3: Power State 3
                {
                }

                Method (_PS0, 0, Serialized)  // _PS0: Power State 0
                {
                    If ((^^^GPO1.AVBL == One))
                    {
                        ^^^GPO1.TCD3 = Zero
                    }

                    Sleep (0x05)
                    If ((^^^I2C5.PMI1.AVBG == One))
                    {
                        ^^^I2C5.PMI1.TCON = One
                    }

                    Sleep (0x1E)
                    If ((^^^GPO1.AVBL == One))
                    {
                        ^^^GPO1.TCD3 = One
                    }

                    Sleep (0x78)
                }

                Method (_CRS, 0, NotSerialized)  // _CRS: Current
Resource Settings
                {
                    Name (RBUF, ResourceTemplate ()
                    {
                        I2cSerialBus (0x0030, ControllerInitiated, 0x00061A80,
                            AddressingMode7Bit, "\\_SB.I2C4",
                            0x00, ResourceConsumer, ,
                            )
                        Interrupt (ResourceConsumer, Level,
ActiveHigh, Exclusive, ,, )
                        {
                            0x00000044,
                        }
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.GPO1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x001A
                            }
                    })
                    Return (RBUF) /* \_SB_.I2C4.TCS5._CRS.RBUF */
                }

                Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
                {
                    Name (_T_1, Zero)  // _T_x: Emitted by ASL Compiler
                    Name (_T_0, Zero)  // _T_x: Emitted by ASL Compiler
                    Debug = "Method _DSM begin"
                    If ((Arg0 == ToUUID
("3cdff6f7-4267-4555-ad05-b30a3d8938de") /* HID I2C Device */))
                    {
                        While (One)
                        {
                            _T_0 = ToInteger (Arg2)
                            If ((_T_0 == Zero))
                            {
                                While (One)
                                {
                                    _T_1 = ToInteger (Arg1)
                                    If ((_T_1 == One))
                                    {
                                        Debug = "Method _DSM Function Query"
                                        Return (Buffer (One)
                                        {
                                             0x03
                       /* . */
                                        })
                                    }
                                    Else
                                    {
                                        Return (Buffer (One)
                                        {
                                             0x00
                       /* . */
                                        })
                                    }

                                    Break
                                }
                            }
                            Else
                            {
                                If ((_T_0 == One))
                                {
                                    Debug = "Method _DSM Function HID"
                                    Return (Zero)
                                }
                                Else
                                {
                                    Return (Zero)
                                }
                            }

                            Break
                        }
                    }
                    Else
                    {
                        Return (Buffer (One)
                        {
                             0x00
       /* . */
                        })
                    }
                }

                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If ((OSSL & 0x80))
                    {
                        Return (Zero)
                    }

                    If ((OSYS == 0x07DD))
                    {
                        Return (0x0F)
                    }
                    Else
                    {
                        Return (0x0F)
                    }
                }
            }
        }

        Device (I2C5)
        {
            Name (_ADR, Zero)  // _ADR: Address
            Name (_HID, "80860F41" /* Intel Baytrail I2C Host
Controller */)  // _HID: Hardware ID
            Name (_CID, "80860F41" /* Intel Baytrail I2C Host
Controller */)  // _CID: Compatible ID
            Name (_DDN, "Intel(R) I2C Controller #5 - 80860F45")  //
_DDN: DOS Device Name
            Name (_UID, 0x05)  // _UID: Unique ID
            Method (_SEM, 0, NotSerialized)
            {
                If ((((PMID == 0x04) || (PMID == 0x05)) || (PMID == 0x06)))
                {
                    ADBG ("$COVE")
                    Return (One)
                }
                Else
                {
                    ADBG ("CCOVE")
                    Return (Zero)
                }
            }

            Name (_DEP, Package (0x01)  // _DEP: Dependencies
            {
                PEPD
            })
            Name (RBUF, ResourceTemplate ()
            {
                Memory32Fixed (ReadWrite,
                    0x00000000,         // Address Base
                    0x00001000,         // Address Length
                    _Y1C)
                Interrupt (ResourceConsumer, Level, ActiveLow, Exclusive, ,, )
                {
                    0x00000024,
                }
                FixedDMA (0x0018, 0x0000, Width32bit, )
                FixedDMA (0x0019, 0x0001, Width32bit, )
            })
            Method (_HRV, 0, NotSerialized)  // _HRV: Hardware Revision
            {
                Return (SOCS) /* \SOCS */
            }

            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
            {
                CreateDWordField (RBUF, \_SB.I2C5._Y1C._BAS, B0BA)  //
_BAS: Base Address
                CreateDWordField (RBUF, \_SB.I2C5._Y1C._LEN, B0LN)  //
_LEN: Length
                B0BA = I50A /* \I50A */
                B0LN = I50L /* \I50L */
                Return (RBUF) /* \_SB_.I2C5.RBUF */
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                If (((I50A == Zero) || (L25D == One)))
                {
                    Return (Zero)
                }

                Return (0x0F)
            }

            Method (_PS3, 0, NotSerialized)  // _PS3: Power State 3
            {
                If ((((PMID == 0x04) || (PMID == 0x05)) || (PMID == 0x06)))
                {
                    Return (Zero)
                }

                PSAT |= 0x03
                Local0 = PSAT /* \_SB_.I2C5.PSAT */
            }

            Method (_PS0, 0, NotSerialized)  // _PS0: Power State 0
            {
                PSAT &= 0xFFFFFFFC
                Local0 = PSAT /* \_SB_.I2C5.PSAT */
            }

            OperationRegion (KEYS, SystemMemory, I51A, 0x0100)
            Field (KEYS, DWordAcc, NoLock, WriteAsZeros)
            {
                Offset (0x84),
                PSAT,   32
            }

            Name (XPMC, ResourceTemplate ()
            {
                I2cSerialBus (0x0034, ControllerInitiated, 0x00061A80,
                    AddressingMode7Bit, "\\_SB.I2C5",
                    0x00, ResourceConsumer, ,
                    )
            })
            OperationRegion (XSCG, GenericSerialBus, Zero, 0x0100)
            Field (XSCG, BufferAcc, NoLock, Preserve)
            {
                Connection (XPMC),
                AccessAs (BufferAcc, AttribByte),
                XP00,   8,
                XP01,   8
            }

            Field (XSCG, BufferAcc, NoLock, Preserve)
            {
                Connection (XPMC),
                Offset (0xB9),
                AccessAs (BufferAcc, AttribByte),
                XPB9,   8
            }

            Field (XSCG, BufferAcc, NoLock, Preserve)
            {
                Connection (XPMC),
                Offset (0x2C),
                AccessAs (BufferAcc, AttribByte),
                XP2C,   8,
                XP2D,   8,
                XP2E,   8,
                XP2F,   8,
                XP30,   8,
                XP31,   8,
                XP32,   8,
                XP33,   8
            }

            Field (XSCG, BufferAcc, NoLock, Preserve)
            {
                Connection (XPMC),
                Offset (0x2C),
                AccessAs (BufferAcc, AttribBytes (0x0A)),
                XPCG,   8
            }
        }

        Scope (I2C5)
        {
            Name (AVBL, Zero)
            Method (_REG, 2, NotSerialized)  // _REG: Region Availability
            {
                If ((Arg0 == 0x09))
                {
                    AVBL = Arg1
                }
            }

            Device (PMI1)
            {
                Name (_ADR, Zero)  // _ADR: Address
                Name (_HID, "INT33F4" /* XPOWER PMIC Controller */)
// _HID: Hardware ID
                Name (_CID, "INT33F4" /* XPOWER PMIC Controller */)
// _CID: Compatible ID
                Name (_DDN, "XPOWER PMIC Controller")  // _DDN: DOS Device Name
                Name (_HRV, 0x02)  // _HRV: Hardware Revision
                Name (_UID, One)  // _UID: Unique ID
                Name (_DEP, Package (0x01)  // _DEP: Dependencies
                {
                    I2C5
                })
                Method (_CRS, 0, NotSerialized)  // _CRS: Current
Resource Settings
                {
                    Name (SBUF, ResourceTemplate ()
                    {
                        I2cSerialBus (0x0034, ControllerInitiated, 0x000F4240,
                            AddressingMode7Bit, "\\_SB.I2C5",
                            0x00, ResourceConsumer, ,
                            )
                        Interrupt (ResourceConsumer, Level,
ActiveHigh, Shared, ,, )
                        {
                            0x00000043,
                        }
                        Interrupt (ResourceConsumer, Level,
ActiveHigh, Shared, ,, )
                        {
                            0x00000043,
                        }
                        Interrupt (ResourceConsumer, Level,
ActiveHigh, Shared, ,, )
                        {
                            0x00000043,
                        }
                    })
                    Return (SBUF) /* \_SB_.I2C5.PMI1._CRS.SBUF */
                }

                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If ((PMEN == Zero))
                    {
                        Return (Zero)
                    }

                    If ((PMID == 0x05))
                    {
                        ADBG ("XPWR_DCOVE")
                        Return (0x0F)
                    }

                    Return (Zero)
                }

                OperationRegion (PMOP, 0x8D, Zero, 0x0100)
                Field (PMOP, DWordAcc, NoLock, Preserve)
                {
                    ALD1,   32,
                    ALD2,   32,
                    ALD3,   32,
                    DLD1,   32,
                    DLD2,   32,
                    DLD3,   32,
                    DLD4,   32,
                    ELD1,   32,
                    ELD2,   32,
                    ELD3,   32,
                    FLD1,   32,
                    FLD2,   32,
                    FLD3,   32,
                    BUC1,   32,
                    BUC2,   32,
                    BUC3,   32,
                    BUC4,   32,
                    BUC5,   32,
                    BUC6,   32,
                    GPI1,   32
                }

                OperationRegion (DPTF, 0x8C, Zero, 0x0100)
                Field (DPTF, DWordAcc, NoLock, Preserve)
                {
                    TMP0,   32,
                    AX00,   32,
                    AX01,   32,
                    TMP1,   32,
                    AX10,   32,
                    AX11,   32,
                    TMP2,   32,
                    AX20,   32,
                    AX21,   32,
                    TMP3,   32,
                    AX30,   32,
                    AX31,   32,
                    TMP4,   32,
                    AX40,   32,
                    AX41,   32,
                    TMP5,   32,
                    AX50,   32,
                    AX51,   32,
                    PEN0,   32,
                    PEN1,   32,
                    PEN2,   32,
                    PEN3,   32,
                    PEN4,   32,
                    PEN5,   32
                }

                Name (LPAT, Package (0x30)
                {
                    0x0C13,
                    0x01F4,
                    0x0C27,
                    0x01D3,
                    0x0C3B,
                    0x01B3,
                    0x0C4F,
                    0x0196,
                    0x0C63,
                    0x017B,
                    0x0C77,
                    0x0162,
                    0x0C8B,
                    0x014C,
                    0x0C9F,
                    0x0136,
                    0x0CB3,
                    0x0122,
                    0x0CC7,
                    0x0110,
                    0x0CDB,
                    0xFF,
                    0x0CEF,
                    0xEF,
                    0x0D03,
                    0xE1,
                    0x0D17,
                    0xD4,
                    0x0D2B,
                    0xC7,
                    0x0D3F,
                    0xBB,
                    0x0D53,
                    0xB0,
                    0x0D67,
                    0xA6,
                    0x0D7B,
                    0x9D,
                    0x0D8F,
                    0x94,
                    0x0DA3,
                    0x8C,
                    0x0DB7,
                    0x83,
                    0x0DCB,
                    0x7C,
                    0x0DDF,
                    0x76
                })
                OperationRegion (GPOP, GeneralPurposeIo, Zero, 0x0100)
                Field (GPOP, ByteAcc, NoLock, Preserve)
                {
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0020
                            }
                    ),
                    GMP0,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0021
                            }
                    ),
                    GX00,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0022
                            }
                    ),
                    GX01,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0023
                            }
                    ),
                    GMP1,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0024
                            }
                    ),
                    GX10,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0025
                            }
                    ),
                    GX11,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0026
                            }
                    ),
                    GMP2,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0027
                            }
                    ),
                    GX20,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0028
                            }
                    ),
                    GX21,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0029
                            }
                    ),
                    GMP3,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x002A
                            }
                    ),
                    GX30,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x002B
                            }
                    ),
                    GX31,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x002C
                            }
                    ),
                    GMP4,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x002D
                            }
                    ),
                    GX40,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x002E
                            }
                    ),
                    GX41,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x002F
                            }
                    ),
                    GMP5,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0030
                            }
                    ),
                    GX50,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0031
                            }
                    ),
                    GX51,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0032
                            }
                    ),
                    GEN0,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0033
                            }
                    ),
                    GEN1,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0034
                            }
                    ),
                    GEN2,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0035
                            }
                    ),
                    GEN3,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0036
                            }
                    ),
                    GEN4,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0037
                            }
                    ),
                    GEN5,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0040
                            }
                    ),
                    G28X,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0041
                            }
                    ),
                    G3P3,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0045
                            }
                    ),
                    GD3X,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0047
                            }
                    ),
                    G15X,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0048
                            }
                    ),
                    G18X,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0049
                            }
                    ),
                    GE18,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x0053
                            }
                    ),
                    GSDX,   1,
                    Connection (
                        GpioIo (Exclusive, PullDefault, 0x0000,
0x0000, IoRestrictionOutputOnly,
                            "\\_SB.I2C5.PMI1", 0x00, ResourceConsumer, ,
                            )
                            {   // Pin list
                                0x000B
                            }
                    ),
                    TCON,   1
                }

                Name (AVBL, Zero)
                Name (AVBD, Zero)
                Name (AVBG, Zero)
                Method (_REG, 2, NotSerialized)  // _REG: Region Availability
                {
                    If ((Arg0 == 0x08))
                    {
                        AVBG = Arg1
                    }

                    If ((Arg0 == 0x8D))
                    {
                        AVBL = Arg1
                    }

                    If ((Arg0 == 0x8C))
                    {
                        AVBD = Arg1
                    }
                }
            }


On Tue, Mar 15, 2016 at 10:26 PM, sergk sergk2mail
<sergk.admin@gmail.com> wrote:
> Hi Jarko,
> Exploring sysfs shows:
>
> ls -l /sys/bus/acpi/devices/CHPN0001:00
> lrwxrwxrwx 1 root root 0 Mar 15 22:08
> /sys/bus/acpi/devices/CHPN0001:00 ->
> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/80860F41:03/CHPN0001:00
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/status
> 0
>
> status is 0 - what does this mean? It is detected via ACPI but not present?
> What does "LNXSYBUS:00/80860F41:03"  means?  Does it mean i2c-3, 0x41
> ?  80860F41:03 == ?
>
> also inside its subfolders I do not see nothing useful:
>
> cat /sys/bus/acpi/devices/CHPN0001:00/adr
> 0x00000000
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/hid
> CHPN0001
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/modalias
> acpi:CHPN0001:PNP0C50:
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/path
> \_SB_.I2C4.TCS5
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/uevent
> MODALIAS=acpi:CHPN0001:PNP0C50:
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/runtime_usage
> 0
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/control
> auto
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/runtime_enabled
> disabled
>
> So the question is the same - how to obtain via acpi in mentioned
> above code i2cbus, bus addr and irq for this touch?
>
> Regards,
>                  Serge Kolotylo.
>
> On Mon, Mar 14, 2016 at 12:21 PM, Jarkko Nikula
> <jarkko.nikula@linux.intel.com> wrote:
>> Hi
>>
>> On 03/13/2016 02:43 PM, sergk sergk2mail wrote:
>>>
>>> Hi All,
>>> Please help to correct create i2c client with ACPI support for device
>>> (touchscreen) on i2c on vanilla 4.4.2 kernel x86_64 Baytrail,
>>> disrtibutive = Arch.
>>> ========================================================
>>> According kernel Documentation I have created such skeleton:
>>>
>>>
>>> #define DEVICE_NAME  "testme"
>>>
>>> static const struct acpi_device_id icn_ts_acpi_match[] = {
>>>      { "CHPN0001", 0 },
>>>      { "PNP05C0", 0 },
>>>      { },
>>> };
>>
>>
>> Touchscreen and PNPxxxx: can it be i2c-hid compatible touchscreen?
>>
>> Those typically have vendor specific ACPI _HID but device is matched using
>> ACPI PNP compatible ID (_CID) "PNP0C50" or "ACPI0C50". See
>> drivers/hid/i2c-hid/i2c-hid.c.
>>
>> Just thinking if you have device with _CID "PNP0C50" and either device is
>> matched before your driver with i2c-hid driver or your driver doesn't probe
>> because "PNP05C0" != "PNP0C50".
>>
>>> MAIN QUESTIONS:
>>>
>>> 1) What is wrong with i2c client driver code? Why it is NOT obtain
>>> info from ACPI DSD table?
>>>
>> Your example looks ok. Another what comes to my mind is the device actually
>> present. Sometimes DSDT tables may specify multiple alternative devices but
>> only one being actually connected. You could check that by reading the
>> device status which reads 15 if the device is present.
>>
>> cat /sys/bus/acpi/devices/ACPI01234/status
>> 15
>>
>>> 2) In which way should be created i2c dev while registering i2c acpi
>>> driver? Who\where\what and how should create this i2c device?
>>>
>> i2c-core registers the i2c devices connected to certain bus when adapter
>> device for that bus is registered in i2c-core.c: i2c_register_adapter().
>>
>> --
>> Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ?
  2016-03-15 22:26   ` sergk sergk2mail
  2016-03-15 23:02     ` sergk sergk2mail
@ 2016-03-15 23:12     ` sergk sergk2mail
  2016-03-23  9:30       ` Jarkko Nikula
  1 sibling, 1 reply; 6+ messages in thread
From: sergk sergk2mail @ 2016-03-15 23:12 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-i2c

Hi,

regarding "80860F41:03"
from DSDT 80860F41:
Name (_HID, "80860F41" /* Intel Baytrail I2C Host Controller */)  //
_HID: Hardware ID
            Name (_CID, "80860F41" /* Intel Baytrail I2C Host
Controller */)  // _CID: Compatible ID


So, is this mean i2c-3?
Regards,
                Serge Kolotylo.

On Tue, Mar 15, 2016 at 10:26 PM, sergk sergk2mail
<sergk.admin@gmail.com> wrote:
> Hi Jarko,
> Exploring sysfs shows:
>
> ls -l /sys/bus/acpi/devices/CHPN0001:00
> lrwxrwxrwx 1 root root 0 Mar 15 22:08
> /sys/bus/acpi/devices/CHPN0001:00 ->
> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/80860F41:03/CHPN0001:00
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/status
> 0
>
> status is 0 - what does this mean? It is detected via ACPI but not present?
> What does "LNXSYBUS:00/80860F41:03"  means?  Does it mean i2c-3, 0x41
> ?  80860F41:03 == ?
>
> also inside its subfolders I do not see nothing useful:
>
> cat /sys/bus/acpi/devices/CHPN0001:00/adr
> 0x00000000
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/hid
> CHPN0001
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/modalias
> acpi:CHPN0001:PNP0C50:
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/path
> \_SB_.I2C4.TCS5
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/uevent
> MODALIAS=acpi:CHPN0001:PNP0C50:
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/runtime_usage
> 0
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/control
> auto
> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/power/runtime_enabled
> disabled
>
> So the question is the same - how to obtain via acpi in mentioned
> above code i2cbus, bus addr and irq for this touch?
>
> Regards,
>                  Serge Kolotylo.
>
> On Mon, Mar 14, 2016 at 12:21 PM, Jarkko Nikula
> <jarkko.nikula@linux.intel.com> wrote:
>> Hi
>>
>> On 03/13/2016 02:43 PM, sergk sergk2mail wrote:
>>>
>>> Hi All,
>>> Please help to correct create i2c client with ACPI support for device
>>> (touchscreen) on i2c on vanilla 4.4.2 kernel x86_64 Baytrail,
>>> disrtibutive = Arch.
>>> ========================================================
>>> According kernel Documentation I have created such skeleton:
>>>
>>>
>>> #define DEVICE_NAME  "testme"
>>>
>>> static const struct acpi_device_id icn_ts_acpi_match[] = {
>>>      { "CHPN0001", 0 },
>>>      { "PNP05C0", 0 },
>>>      { },
>>> };
>>
>>
>> Touchscreen and PNPxxxx: can it be i2c-hid compatible touchscreen?
>>
>> Those typically have vendor specific ACPI _HID but device is matched using
>> ACPI PNP compatible ID (_CID) "PNP0C50" or "ACPI0C50". See
>> drivers/hid/i2c-hid/i2c-hid.c.
>>
>> Just thinking if you have device with _CID "PNP0C50" and either device is
>> matched before your driver with i2c-hid driver or your driver doesn't probe
>> because "PNP05C0" != "PNP0C50".
>>
>>> MAIN QUESTIONS:
>>>
>>> 1) What is wrong with i2c client driver code? Why it is NOT obtain
>>> info from ACPI DSD table?
>>>
>> Your example looks ok. Another what comes to my mind is the device actually
>> present. Sometimes DSDT tables may specify multiple alternative devices but
>> only one being actually connected. You could check that by reading the
>> device status which reads 15 if the device is present.
>>
>> cat /sys/bus/acpi/devices/ACPI01234/status
>> 15
>>
>>> 2) In which way should be created i2c dev while registering i2c acpi
>>> driver? Who\where\what and how should create this i2c device?
>>>
>> i2c-core registers the i2c devices connected to certain bus when adapter
>> device for that bus is registered in i2c-core.c: i2c_register_adapter().
>>
>> --
>> Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ?
  2016-03-15 23:12     ` sergk sergk2mail
@ 2016-03-23  9:30       ` Jarkko Nikula
  0 siblings, 0 replies; 6+ messages in thread
From: Jarkko Nikula @ 2016-03-23  9:30 UTC (permalink / raw)
  To: sergk sergk2mail; +Cc: linux-i2c

Hi

Sorry the delay. Answers below.

On 03/16/2016 01:12 AM, sergk sergk2mail wrote:
> Hi,
>
> regarding "80860F41:03"
> from DSDT 80860F41:
> Name (_HID, "80860F41" /* Intel Baytrail I2C Host Controller */)  //
> _HID: Hardware ID
>              Name (_CID, "80860F41" /* Intel Baytrail I2C Host
> Controller */)  // _CID: Compatible ID
>
>
> So, is this mean i2c-3?

It's third i2c-designware compatible I2C host controller but it doesn't 
necessarily map into i2c-3. For instance if there are other I2C host 
controller drivers like SMBUS or those in display controller initialized 
before it.

>> ls -l /sys/bus/acpi/devices/CHPN0001:00
>> lrwxrwxrwx 1 root root 0 Mar 15 22:08
>> /sys/bus/acpi/devices/CHPN0001:00 ->
>> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/80860F41:03/CHPN0001:00
>> root@archiso ~ # cat /sys/bus/acpi/devices/CHPN0001:00/status
>> 0
>>
>> status is 0 - what does this mean? It is detected via ACPI but not present?
>> What does "LNXSYBUS:00/80860F41:03"  means?  Does it mean i2c-3, 0x41
>> ?  80860F41:03 == ?
>>
Path shows the complete device hierarchy where CHPN0001:00 is under 
80860F41:03 bus but not present. Looking at the DSDT snippet you posted 
into thread there is _STA method that forms the above status:

                 Method (_STA, 0, NotSerialized)  // _STA: Status
                 {
                     If ((OSSL & 0x80))
                     {
                         Return (Zero)
                     }

                     If ((OSYS == 0x07DD))
                     {
                         Return (0x0F)
                     }
                     Else
                     {
                         Return (0x0F)
                     }
                 }

I don't know what these OSSL and OSYS variables are. I guess OSSL 
represents either some BIOS configuration or alternative device 
manufacturer can use. Is there other similar device defined under 
80860F41:03 that could be present (status == 15)?

The _DSM method shows it indeeds is an i2c-hid device and no new driver 
is required:

                 Method (_DSM, 4, Serialized)  // _DSM: Device-Specific 
Method
                 {
                     Name (_T_1, Zero)  // _T_x: Emitted by ASL Compiler
                     Name (_T_0, Zero)  // _T_x: Emitted by ASL Compiler
                     Debug = "Method _DSM begin"
                     If ((Arg0 == ToUUID
("3cdff6f7-4267-4555-ad05-b30a3d8938de") /* HID I2C Device */))

This same UUID is matched in drivers/hid/i2c-hid/i2c-hid.c: 
i2c_hid_acpi_pdata().

>> So the question is the same - how to obtain via acpi in mentioned
>> above code i2cbus, bus addr and irq for this touch?
>>
Look up happens in acpi_i2c_add_device() and acpi_i2c_find_address() in 
drivers/i2c/i2c-core.c but device must be present.

-- 
Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-23  9:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-13 12:43 I2c client driver + ACPI on Baytrail & kernel 4.4.2 = ? sergk sergk2mail
2016-03-14 12:21 ` Jarkko Nikula
2016-03-15 22:26   ` sergk sergk2mail
2016-03-15 23:02     ` sergk sergk2mail
2016-03-15 23:12     ` sergk sergk2mail
2016-03-23  9:30       ` Jarkko Nikula

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.