Skip to content

Commit 13aad34

Browse files
committed
Merge tag 'platform-drivers-x86-int3472-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 into regulator-5.17
Signed tag for the immutable platform-drivers-x86-int3472 branch This branch contains 5.16-rc1 + the pending ACPI/i2c, tps68570 platform_data and INT3472 driver patches required so that the tps68570 regulator driver can be applied.
2 parents c57dbca + 97c2259 commit 13aad34

File tree

14 files changed

+473
-161
lines changed

14 files changed

+473
-161
lines changed

drivers/acpi/scan.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,12 @@ static const char * const acpi_ignore_dep_ids[] = {
797797
NULL
798798
};
799799

800+
/* List of HIDs for which we honor deps of matching ACPI devs, when checking _DEP lists. */
801+
static const char * const acpi_honor_dep_ids[] = {
802+
"INT3472", /* Camera sensor PMIC / clk and regulator info */
803+
NULL
804+
};
805+
800806
static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
801807
{
802808
struct acpi_device *device = NULL;
@@ -1762,8 +1768,12 @@ static void acpi_scan_dep_init(struct acpi_device *adev)
17621768
struct acpi_dep_data *dep;
17631769

17641770
list_for_each_entry(dep, &acpi_dep_list, node) {
1765-
if (dep->consumer == adev->handle)
1771+
if (dep->consumer == adev->handle) {
1772+
if (dep->honor_dep)
1773+
adev->flags.honor_deps = 1;
1774+
17661775
adev->dep_unmet++;
1776+
}
17671777
}
17681778
}
17691779

@@ -1967,7 +1977,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
19671977
for (count = 0, i = 0; i < dep_devices.count; i++) {
19681978
struct acpi_device_info *info;
19691979
struct acpi_dep_data *dep;
1970-
bool skip;
1980+
bool skip, honor_dep;
19711981

19721982
status = acpi_get_object_info(dep_devices.handles[i], &info);
19731983
if (ACPI_FAILURE(status)) {
@@ -1976,6 +1986,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
19761986
}
19771987

19781988
skip = acpi_info_matches_ids(info, acpi_ignore_dep_ids);
1989+
honor_dep = acpi_info_matches_ids(info, acpi_honor_dep_ids);
19791990
kfree(info);
19801991

19811992
if (skip)
@@ -1989,6 +2000,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
19892000

19902001
dep->supplier = dep_devices.handles[i];
19912002
dep->consumer = handle;
2003+
dep->honor_dep = honor_dep;
19922004

19932005
mutex_lock(&acpi_dep_list_lock);
19942006
list_add_tail(&dep->node , &acpi_dep_list);
@@ -2155,8 +2167,8 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass)
21552167
register_dock_dependent_device(device, ejd);
21562168

21572169
acpi_bus_get_status(device);
2158-
/* Skip devices that are not present. */
2159-
if (!acpi_device_is_present(device)) {
2170+
/* Skip devices that are not ready for enumeration (e.g. not present) */
2171+
if (!acpi_dev_ready_for_enumeration(device)) {
21602172
device->flags.initialized = false;
21612173
acpi_device_clear_enumerated(device);
21622174
device->flags.power_manageable = 0;
@@ -2318,6 +2330,23 @@ void acpi_dev_clear_dependencies(struct acpi_device *supplier)
23182330
}
23192331
EXPORT_SYMBOL_GPL(acpi_dev_clear_dependencies);
23202332

2333+
/**
2334+
* acpi_dev_ready_for_enumeration - Check if the ACPI device is ready for enumeration
2335+
* @device: Pointer to the &struct acpi_device to check
2336+
*
2337+
* Check if the device is present and has no unmet dependencies.
2338+
*
2339+
* Return true if the device is ready for enumeratino. Otherwise, return false.
2340+
*/
2341+
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device)
2342+
{
2343+
if (device->flags.honor_deps && device->dep_unmet)
2344+
return false;
2345+
2346+
return acpi_device_is_present(device);
2347+
}
2348+
EXPORT_SYMBOL_GPL(acpi_dev_ready_for_enumeration);
2349+
23212350
/**
23222351
* acpi_dev_get_first_consumer_dev - Return ACPI device dependent on @supplier
23232352
* @supplier: Pointer to the dependee device

drivers/i2c/i2c-core-acpi.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev,
144144
struct list_head resource_list;
145145
int ret;
146146

147-
if (acpi_bus_get_status(adev) || !adev->status.present)
147+
if (acpi_bus_get_status(adev))
148148
return -EINVAL;
149149

150+
if (!acpi_dev_ready_for_enumeration(adev))
151+
return -ENODEV;
152+
150153
if (acpi_match_device_ids(adev, i2c_acpi_ignored_device_ids) == 0)
151154
return -ENODEV;
152155

@@ -473,8 +476,8 @@ struct notifier_block i2c_acpi_notifier = {
473476
};
474477

475478
/**
476-
* i2c_acpi_new_device - Create i2c-client for the Nth I2cSerialBus resource
477-
* @dev: Device owning the ACPI resources to get the client from
479+
* i2c_acpi_new_device_by_fwnode - Create i2c-client for the Nth I2cSerialBus resource
480+
* @fwnode: fwnode with the ACPI resources to get the client from
478481
* @index: Index of ACPI resource to get
479482
* @info: describes the I2C device; note this is modified (addr gets set)
480483
* Context: can sleep
@@ -490,15 +493,20 @@ struct notifier_block i2c_acpi_notifier = {
490493
* Returns a pointer to the new i2c-client, or error pointer in case of failure.
491494
* Specifically, -EPROBE_DEFER is returned if the adapter is not found.
492495
*/
493-
struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
494-
struct i2c_board_info *info)
496+
struct i2c_client *i2c_acpi_new_device_by_fwnode(struct fwnode_handle *fwnode,
497+
int index,
498+
struct i2c_board_info *info)
495499
{
496-
struct acpi_device *adev = ACPI_COMPANION(dev);
497500
struct i2c_acpi_lookup lookup;
498501
struct i2c_adapter *adapter;
502+
struct acpi_device *adev;
499503
LIST_HEAD(resource_list);
500504
int ret;
501505

506+
adev = to_acpi_device_node(fwnode);
507+
if (!adev)
508+
return ERR_PTR(-ENODEV);
509+
502510
memset(&lookup, 0, sizeof(lookup));
503511
lookup.info = info;
504512
lookup.device_handle = acpi_device_handle(adev);
@@ -520,7 +528,7 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
520528

521529
return i2c_new_client_device(adapter, info);
522530
}
523-
EXPORT_SYMBOL_GPL(i2c_acpi_new_device);
531+
EXPORT_SYMBOL_GPL(i2c_acpi_new_device_by_fwnode);
524532

525533
bool i2c_acpi_waive_d0_probe(struct device *dev)
526534
{
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472.o
2-
intel_skl_int3472-y := intel_skl_int3472_common.o \
3-
intel_skl_int3472_discrete.o \
4-
intel_skl_int3472_tps68470.o \
5-
intel_skl_int3472_clk_and_regulator.o
1+
obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472_discrete.o \
2+
intel_skl_int3472_tps68470.o
3+
intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o common.o
4+
intel_skl_int3472_tps68470-y := tps68470.o tps68470_board_data.o common.o

drivers/platform/x86/intel/int3472/intel_skl_int3472_clk_and_regulator.c renamed to drivers/platform/x86/intel/int3472/clk_and_regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/regulator/driver.h>
1010
#include <linux/slab.h>
1111

12-
#include "intel_skl_int3472_common.h"
12+
#include "common.h"
1313

1414
/*
1515
* The regulators have to have .ops to be valid, but the only ops we actually
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Author: Dan Scally <[email protected]> */
3+
4+
#include <linux/acpi.h>
5+
#include <linux/slab.h>
6+
7+
#include "common.h"
8+
9+
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *id)
10+
{
11+
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
12+
acpi_handle handle = adev->handle;
13+
union acpi_object *obj;
14+
acpi_status status;
15+
16+
status = acpi_evaluate_object(handle, id, NULL, &buffer);
17+
if (ACPI_FAILURE(status))
18+
return ERR_PTR(-ENODEV);
19+
20+
obj = buffer.pointer;
21+
if (!obj)
22+
return ERR_PTR(-ENODEV);
23+
24+
if (obj->type != ACPI_TYPE_BUFFER) {
25+
acpi_handle_err(handle, "%s object is not an ACPI buffer\n", id);
26+
kfree(obj);
27+
return ERR_PTR(-EINVAL);
28+
}
29+
30+
return obj;
31+
}
32+
33+
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
34+
{
35+
union acpi_object *obj;
36+
int ret;
37+
38+
obj = skl_int3472_get_acpi_buffer(adev, "CLDB");
39+
if (IS_ERR(obj))
40+
return PTR_ERR(obj);
41+
42+
if (obj->buffer.length > sizeof(*cldb)) {
43+
acpi_handle_err(adev->handle, "The CLDB buffer is too large\n");
44+
ret = -EINVAL;
45+
goto out_free_obj;
46+
}
47+
48+
memcpy(cldb, obj->buffer.pointer, obj->buffer.length);
49+
ret = 0;
50+
51+
out_free_obj:
52+
kfree(obj);
53+
return ret;
54+
}
55+
56+
/* sensor_adev_ret may be NULL, name_ret must not be NULL */
57+
int skl_int3472_get_sensor_adev_and_name(struct device *dev,
58+
struct acpi_device **sensor_adev_ret,
59+
const char **name_ret)
60+
{
61+
struct acpi_device *adev = ACPI_COMPANION(dev);
62+
struct acpi_device *sensor;
63+
int ret = 0;
64+
65+
sensor = acpi_dev_get_first_consumer_dev(adev);
66+
if (!sensor) {
67+
dev_err(dev, "INT3472 seems to have no dependents.\n");
68+
return -ENODEV;
69+
}
70+
71+
*name_ret = devm_kasprintf(dev, GFP_KERNEL, I2C_DEV_NAME_FORMAT,
72+
acpi_dev_name(sensor));
73+
if (!*name_ret)
74+
ret = -ENOMEM;
75+
76+
if (ret == 0 && sensor_adev_ret)
77+
*sensor_adev_ret = sensor;
78+
else
79+
acpi_dev_put(sensor);
80+
81+
return ret;
82+
}

drivers/platform/x86/intel/int3472/intel_skl_int3472_common.h renamed to drivers/platform/x86/intel/int3472/common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ struct int3472_discrete_device {
105105
struct gpiod_lookup_table gpios;
106106
};
107107

108-
int skl_int3472_discrete_probe(struct platform_device *pdev);
109-
int skl_int3472_discrete_remove(struct platform_device *pdev);
110-
int skl_int3472_tps68470_probe(struct i2c_client *client);
111108
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
112109
char *id);
113110
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
111+
int skl_int3472_get_sensor_adev_and_name(struct device *dev,
112+
struct acpi_device **sensor_adev_ret,
113+
const char **name_ret);
114114

115115
int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
116116
void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);

drivers/platform/x86/intel/int3472/intel_skl_int3472_discrete.c renamed to drivers/platform/x86/intel/int3472/discrete.c

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/platform_device.h>
1515
#include <linux/uuid.h>
1616

17-
#include "intel_skl_int3472_common.h"
17+
#include "common.h"
1818

1919
/*
2020
* 79234640-9e10-4fea-a5c1-b5aa8b19756f
@@ -332,7 +332,9 @@ static int skl_int3472_parse_crs(struct int3472_discrete_device *int3472)
332332
return 0;
333333
}
334334

335-
int skl_int3472_discrete_probe(struct platform_device *pdev)
335+
static int skl_int3472_discrete_remove(struct platform_device *pdev);
336+
337+
static int skl_int3472_discrete_probe(struct platform_device *pdev)
336338
{
337339
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
338340
struct int3472_discrete_device *int3472;
@@ -361,19 +363,10 @@ int skl_int3472_discrete_probe(struct platform_device *pdev)
361363
int3472->dev = &pdev->dev;
362364
platform_set_drvdata(pdev, int3472);
363365

364-
int3472->sensor = acpi_dev_get_first_consumer_dev(adev);
365-
if (!int3472->sensor) {
366-
dev_err(&pdev->dev, "INT3472 seems to have no dependents.\n");
367-
return -ENODEV;
368-
}
369-
370-
int3472->sensor_name = devm_kasprintf(int3472->dev, GFP_KERNEL,
371-
I2C_DEV_NAME_FORMAT,
372-
acpi_dev_name(int3472->sensor));
373-
if (!int3472->sensor_name) {
374-
ret = -ENOMEM;
375-
goto err_put_sensor;
376-
}
366+
ret = skl_int3472_get_sensor_adev_and_name(&pdev->dev, &int3472->sensor,
367+
&int3472->sensor_name);
368+
if (ret)
369+
return ret;
377370

378371
/*
379372
* Initialising this list means we can call gpiod_remove_lookup_table()
@@ -387,15 +380,11 @@ int skl_int3472_discrete_probe(struct platform_device *pdev)
387380
return ret;
388381
}
389382

383+
acpi_dev_clear_dependencies(adev);
390384
return 0;
391-
392-
err_put_sensor:
393-
acpi_dev_put(int3472->sensor);
394-
395-
return ret;
396385
}
397386

398-
int skl_int3472_discrete_remove(struct platform_device *pdev)
387+
static int skl_int3472_discrete_remove(struct platform_device *pdev)
399388
{
400389
struct int3472_discrete_device *int3472 = platform_get_drvdata(pdev);
401390

@@ -411,3 +400,23 @@ int skl_int3472_discrete_remove(struct platform_device *pdev)
411400

412401
return 0;
413402
}
403+
404+
static const struct acpi_device_id int3472_device_id[] = {
405+
{ "INT3472", 0 },
406+
{ }
407+
};
408+
MODULE_DEVICE_TABLE(acpi, int3472_device_id);
409+
410+
static struct platform_driver int3472_discrete = {
411+
.driver = {
412+
.name = "int3472-discrete",
413+
.acpi_match_table = int3472_device_id,
414+
},
415+
.probe = skl_int3472_discrete_probe,
416+
.remove = skl_int3472_discrete_remove,
417+
};
418+
module_platform_driver(int3472_discrete);
419+
420+
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Discrete Device Driver");
421+
MODULE_AUTHOR("Daniel Scally <[email protected]>");
422+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)