X86 platform drivers
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Pali Rohár" <pali@kernel.org>
Cc: "Jean Delvare" <jdelvare@suse.com>,
	"Andi Shyti" <andi.shyti@kernel.org>,
	"Eric Piel" <eric.piel@tremplin-utc.net>,
	"Paul Menzel" <pmenzel@molgen.mpg.de>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	Dell.Client.Kernel@dell.com, "Marius Hoch" <mail@mariushoch.de>,
	"Kai Heng Feng" <kai.heng.feng@canonical.com>,
	"Wolfram Sang" <wsa@kernel.org>,
	platform-driver-x86@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH 3/6] platform/x86: dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-smo8800
Date: Sat, 6 Jan 2024 13:13:01 +0100	[thread overview]
Message-ID: <821bfe95-8ace-4f6d-acdc-5771cb72b276@redhat.com> (raw)
In-Reply-To: <20240105182603.2bpvszkl7u7n4xyj@pali>

Hi,

On 1/5/24 19:26, Pali Rohár wrote:
> On Friday 05 January 2024 17:31:32 Hans de Goede wrote:
>> Hi Pali,
>>
>> On 12/24/23 22:55, Pali Rohár wrote:
>>> On Sunday 24 December 2023 22:36:19 Hans de Goede wrote:
>>>> +static int smo8800_find_i801(struct device *dev, void *data)
>>>> +{
>>>> +	static const u16 i801_idf_pci_device_ids[] = {
>>>> +		0x1d70, /* Patsburg (PCH) */
>>>> +		0x1d71, /* Patsburg (PCH) */
>>>> +		0x1d72, /* Patsburg (PCH) */
>>>> +		0x8d7d, /* Wellsburg (PCH) */
>>>> +		0x8d7e, /* Wellsburg (PCH) */
>>>> +		0x8d7f, /* Wellsburg (PCH) */
>>>> +	};
>>>
>>> I'm not happy with seeing another hardcoded list of device ids in the
>>> driver. Are not we able to find compatible i801 adapter without need to
>>> hardcode this list there in smo driver?
>>
>> I agree that having this hardcoded is not ideal.
>>
>> The problem is that for a couple of generations (Patsburg is for
>> Sandy Bridge and Ivybridge and Wellsburg is for Haswell and Broadwell)
>> intel had multiple i2c-i801 controllers / I2C-busses in the PCH
>> and the i2c_client needs to be instantiated on the primary
>> i2c-i801 (compatible) controller.
>>
>> Luckily Intel has only done this for these 2 generations PCH
>> all older and newer PCHs only have 1 i2c-i801 I2C bus.
>>
>> So even though having this hardcoded is not ideal,
>> the list should never change since it is only for
>> this 2 somewhat old PCH generations and new generations
>> are not impacted. So I believe that this is the best
>> solution.
> 
> I see. Seems that this is the best solution which we have.
> 
> Anyway, is not possible to use pci_dev_driver() to find i801 driver and
> from it takes that list of devices which have FEATURE_IDF flag? I have
> looked at the code only quickly and maybe it could be possible. Just an
> idea.

That is an interesting idea, but ...

that would mean interpreting the driver_data set by the i2c-i801
driver inside the dell-smo8800 code, so this would basically rely on
the meaning of that driver_data never changing. I would rather just
duplicate the 6 PCI ids and decouple the 2 drivers.

Regards,

Hans




>>>> +	struct i2c_adapter *adap, **adap_ret = data;
>>>> +	struct pci_dev *pdev;
>>>> +	int i;
>>>> +
>>>> +	adap = i2c_verify_adapter(dev);
>>>> +	if (!adap)
>>>> +		return 0;
>>>> +
>>>> +	if (!strstarts(adap->name, "SMBus I801 adapter"))
>>>> +		return 0;
>>>> +
>>>> +	/* The parent of an I801 adapter is always a PCI device */
>>>> +	pdev = to_pci_dev(adap->dev.parent);
>>>> +	for (i = 0; i < ARRAY_SIZE(i801_idf_pci_device_ids); i++) {
>>>> +		if (pdev->device == i801_idf_pci_device_ids[i])
>>>> +			return 0; /* Only register client on main SMBus channel */
>>>> +	}
>>>> +
>>>> +	*adap_ret = i2c_get_adapter(adap->nr);
>>>> +	return 1;
>>>> +}
>>>
>>
> 


  reply	other threads:[~2024-01-06 12:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-24 21:36 [PATCH 0/6] i2c-i801 / dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-smo8800 Hans de Goede
2023-12-24 21:36 ` [PATCH 1/6] platform/x86: dell-smo8800: Only load on Dell laptops Hans de Goede
2023-12-24 21:48   ` Pali Rohár
2024-01-05 16:25     ` Hans de Goede
2023-12-24 21:36 ` [PATCH 2/6] platform/x86: dell-smo8800: Change probe() ordering a bit Hans de Goede
2023-12-24 21:36 ` [PATCH 3/6] platform/x86: dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-smo8800 Hans de Goede
2023-12-24 21:55   ` Pali Rohár
2024-01-05 16:31     ` Hans de Goede
2024-01-05 18:26       ` Pali Rohár
2024-01-06 12:13         ` Hans de Goede [this message]
2024-01-06 12:16           ` Pali Rohár
2023-12-25 20:00   ` Andy Shevchenko
2024-01-08  9:40   ` kernel test robot
2023-12-24 21:36 ` [PATCH 4/6] platform/x86: dell-smo8800: Pass the IRQ to the lis3lv02d i2c_client Hans de Goede
2024-01-08 17:28   ` kernel test robot
2023-12-24 21:36 ` [PATCH 5/6] platform/x86: dell-smo8800: Instantiate an i2c_client for the IIO st_accel driver Hans de Goede
2023-12-24 22:03   ` Pali Rohár
2024-01-05 16:34     ` Hans de Goede
2024-01-05 18:33       ` Pali Rohár
2024-01-05 18:37       ` Andy Shevchenko
2024-01-05 19:04         ` Andy Shevchenko
2024-01-05 19:20           ` Pali Rohár
2024-01-05 19:46             ` Hans de Goede
2024-01-09  2:00   ` kernel test robot
2023-12-24 21:36 ` [PATCH 6/6] platform/x86: dell-smo8800: Add support for probing for the accelerometer i2c address Hans de Goede
2023-12-24 22:07   ` Pali Rohár
2024-01-05 16:36     ` Hans de Goede
2024-01-05 18:51       ` Pali Rohár
2024-01-06 14:30         ` Hans de Goede
2024-01-08 13:22       ` Dell contacts (was: [PATCH 6/6] platform/x86: dell-smo8800: Add support for probing for the accelerometer i2c address) Paul Menzel
2024-01-08 14:06         ` Greg KH
2024-01-06 14:23 ` [PATCH 0/6] i2c-i801 / dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-smo8800 Paul Menzel
2024-01-06 16:15   ` Hans de Goede
2024-01-08 11:29     ` Paul Menzel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=821bfe95-8ace-4f6d-acdc-5771cb72b276@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=andi.shyti@kernel.org \
    --cc=andy@kernel.org \
    --cc=eric.piel@tremplin-utc.net \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jdelvare@suse.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mail@mariushoch.de \
    --cc=pali@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=pmenzel@molgen.mpg.de \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox