Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ov5693 and intel-skl-int3472 drivers #86

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions drivers/acpi/acpi_lpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,30 @@ static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
return bus_find_device(&pci_bus_type, NULL, &data, match_hid_uid);
}

static bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
{
struct acpi_handle_list dep_devices;
acpi_status status;
int i;

if (!acpi_has_method(adev->handle, "_DEP"))
return false;

status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
&dep_devices);
if (ACPI_FAILURE(status)) {
dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
return false;
}

for (i = 0; i < dep_devices.count; i++) {
if (dep_devices.handles[i] == handle)
return true;
}

return false;
}

static void acpi_lpss_link_consumer(struct device *dev1,
const struct lpss_device_links *link)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ static int acpi_ec_add(struct acpi_device *device)
WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);

/* Reprobe devices depending on the EC */
acpi_walk_dep_device_list(ec->handle);
acpi_dev_flag_dependency_met(ec->handle);

acpi_handle_debug(ec->handle, "enumerated.\n");
return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ static inline void acpi_lpss_init(void) {}
#endif

void acpi_apd_init(void);
bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle);

acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
bool acpi_queue_hotplug_work(struct work_struct *work);
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/pmic/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ endif # PMIC_OPREGION

config TPS68470_PMIC_OPREGION
bool "ACPI operation region support for TPS68470 PMIC"
depends on MFD_TPS68470
help
This config adds ACPI operation region support for TI TPS68470 PMIC.
TPS68470 device is an advanced power management unit that powers
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/pmic/intel_pmic_chtdc_ti.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)
return err;

/* Re-enumerate devices depending on PMIC */
acpi_walk_dep_device_list(ACPI_HANDLE(pdev->dev.parent));
acpi_dev_flag_dependency_met(ACPI_HANDLE(pdev->dev.parent));
return 0;
}

Expand Down
106 changes: 88 additions & 18 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ static DEFINE_MUTEX(acpi_hp_context_lock);
*/
static u64 spcr_uart_addr;

struct acpi_dep_data {
struct list_head node;
acpi_handle supplier;
acpi_handle consumer;
};

void acpi_scan_lock_acquire(void)
{
mutex_lock(&acpi_scan_lock);
Expand Down Expand Up @@ -2114,30 +2108,106 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass)
device->handler->hotplug.notify_online(device);
}

void acpi_walk_dep_device_list(acpi_handle handle)
static int __acpi_dev_get_dependent_dev(struct acpi_dep_data *dep, void *data)
{
struct acpi_device *adev;
int ret;

ret = acpi_bus_get_device(dep->consumer, &adev);
if (ret)
/* If we don't find an adev then we want to continue parsing */
return 0;

*(struct acpi_device **)data = adev;

return 1;
}

static int __acpi_dev_flag_dependency_met(struct acpi_dep_data *dep,
void *data)
{
struct acpi_dep_data *dep, *tmp;
struct acpi_device *adev;

acpi_bus_get_device(dep->consumer, &adev);
if (!adev)
return 0;

adev->dep_unmet--;
if (!adev->dep_unmet)
acpi_bus_attach(adev, true);

list_del(&dep->node);
kfree(dep);
return 0;
}

/**
* acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list
* @handle: The ACPI handle of the supplier device
* @callback: Pointer to the callback function to apply
* @data: Pointer to some data to pass to the callback
*
* The return value of the callback determines this function's behaviour. If 0
* is returned we continue to iterate over acpi_dep_list. If a positive value
* is returned then the loop is broken but this function returns 0. If a
* negative value is returned by the callback then the loop is broken and that
* value is returned as the final error.
*/
int acpi_walk_dep_device_list(acpi_handle handle,
int (*callback)(struct acpi_dep_data *, void *),
void *data)
{
struct acpi_dep_data *dep, *tmp;
int ret;

mutex_lock(&acpi_dep_list_lock);
list_for_each_entry_safe(dep, tmp, &acpi_dep_list, node) {
if (dep->supplier == handle) {
acpi_bus_get_device(dep->consumer, &adev);

if (adev) {
adev->dep_unmet--;
if (!adev->dep_unmet)
acpi_bus_attach(adev, true);
}

list_del(&dep->node);
kfree(dep);
ret = callback(dep, data);
qzed marked this conversation as resolved.
Show resolved Hide resolved
if (ret)
break;
}
}
mutex_unlock(&acpi_dep_list_lock);

return ret > 0 ? 0 : ret;
}
EXPORT_SYMBOL_GPL(acpi_walk_dep_device_list);

/**
* acpi_dev_flag_dependency_met() - Inform consumers of @handle that the device
* is now active
* @handle: acpi_handle for the supplier device
*
* This function walks through the dependencies list and informs each consumer
* of @handle that their dependency upon it is now met. Devices with no more
* unmet dependencies will be attached to the acpi bus.
*/
void acpi_dev_flag_dependency_met(acpi_handle handle)
{
acpi_walk_dep_device_list(handle, __acpi_dev_flag_dependency_met, NULL);
}
EXPORT_SYMBOL_GPL(acpi_dev_flag_dependency_met);

/**
* acpi_dev_get_dependent_dev - Return ACPI device dependent on @supplier
* @supplier: Pointer to the dependee device
*
* Returns the first &struct acpi_device which declares itself dependent on
* @supplier via the _DEP buffer, parsed from the acpi_dep_list.
*/
struct acpi_device *
acpi_dev_get_dependent_dev(struct acpi_device *supplier)
{
struct acpi_device *adev = NULL;

acpi_walk_dep_device_list(supplier->handle,
__acpi_dev_get_dependent_dev, &adev);

return adev;
}
EXPORT_SYMBOL_GPL(acpi_dev_get_dependent_dev);

/**
* acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
* @handle: Root of the namespace scope to scan.
Expand Down
58 changes: 0 additions & 58 deletions drivers/acpi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,42 +807,6 @@ static int acpi_dev_match_cb(struct device *dev, const void *data)
return hrv == match->hrv;
}

bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
{
struct acpi_handle_list dep_devices;
acpi_status status;
int i;

if (!acpi_has_method(adev->handle, "_DEP"))
return false;

status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
&dep_devices);
if (ACPI_FAILURE(status)) {
dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
return false;
}

for (i = 0; i < dep_devices.count; i++) {
if (dep_devices.handles[i] == handle)
return true;
}

return false;
}

static int acpi_dev_match_by_dep(struct device *dev, const void *data)
{
struct acpi_device *adev = to_acpi_device(dev);
const struct acpi_device *dependee = data;
acpi_handle handle = dependee->handle;

if (acpi_lpss_dep(adev, handle))
return 1;

return 0;
}

/**
* acpi_dev_present - Detect that a given ACPI device is present
* @hid: Hardware ID of the device.
Expand Down Expand Up @@ -878,28 +842,6 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
}
EXPORT_SYMBOL(acpi_dev_present);

/**
* acpi_dev_get_next_dep_dev - Return next ACPI device dependent on input dev
* @adev: Pointer to the dependee device
* @prev: Pointer to the previous dependent device (or NULL for first match)
*
* Return the next ACPI device which declares itself dependent on @adev in
* the _DEP buffer.
*
* The caller is responsible to call put_device() on the returned device.
*/
struct acpi_device *acpi_dev_get_next_dep_dev(struct acpi_device *adev,
struct acpi_device *prev)
{
struct device *start = prev ? &prev->dev : NULL;
struct device *dev;

dev = bus_find_device(&acpi_bus_type, start, adev, acpi_dev_match_by_dep);

return dev ? to_acpi_device(dev) : NULL;
}
EXPORT_SYMBOL(acpi_dev_get_next_dep_dev);

/**
* acpi_dev_get_next_match_dev - Return the next match of ACPI device
* @adev: Pointer to the previous acpi_device matching this @hid, @uid and @hrv
Expand Down
1 change: 1 addition & 0 deletions drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ config GPIO_TPS65912

config GPIO_TPS68470
bool "TPS68470 GPIO"
depends on MFD_TPS68470
help
Select this option to enable GPIO driver for the TPS68470
chip family.
Expand Down
37 changes: 32 additions & 5 deletions drivers/gpio/gpiolib-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
}

/**
* acpi_get_gpiod() - Translate ACPI GPIO pin to GPIO descriptor usable with GPIO API
* __acpi_get_gpiod() - Translate ACPI GPIO pin to GPIO descriptor usable with
* GPIO API
* @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
* @pin: ACPI GPIO pin number (0-based, controller-relative)
*
Expand All @@ -111,7 +112,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
* controller does not have GPIO chip registered at the moment. This is to
* support probe deferral.
*/
struct gpio_desc *acpi_get_gpiod(char *path, int pin)
static struct gpio_desc *__acpi_get_gpiod(char *path, int pin)
{
struct gpio_chip *chip;
acpi_handle handle;
Expand All @@ -127,6 +128,32 @@ struct gpio_desc *acpi_get_gpiod(char *path, int pin)

return gpiochip_get_desc(chip, pin);
}

/**
* acpi_get_gpiod() - Translate ACPI GPIO pin to GPIO descriptor usable with
* GPIO API, and hold a refcount to the GPIO device.
* @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
* @pin: ACPI GPIO pin number (0-based, controller-relative)
* @label: Label to pass to gpiod_request()
*
* This function is a simple pass-through to __acpi_get_gpiod(), except that as
* it is intended for use outside of the GPIO layer (in a similar fashion to
* gpiod_get_index() for example) it also holds a reference to the GPIO device.
*/
struct gpio_desc *acpi_get_gpiod(char *path, int pin, char *label)
{
struct gpio_desc *gpio = __acpi_get_gpiod(path, pin);
int ret;

if (IS_ERR(gpio))
return gpio;

ret = gpiod_request(gpio, label);
if (ret)
return ERR_PTR(ret);

return gpio;
}
EXPORT_SYMBOL_GPL(acpi_get_gpiod);

static irqreturn_t acpi_gpio_irq_handler(int irq, void *data)
Expand Down Expand Up @@ -690,8 +717,8 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
if (pin_index >= agpio->pin_table_length)
return 1;

lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
agpio->pin_table[pin_index]);
lookup->desc = __acpi_get_gpiod(agpio->resource_source.string_ptr,
agpio->pin_table[pin_index]);
lookup->info.pin_config = agpio->pin_config;
lookup->info.debounce = agpio->debounce_timeout;
lookup->info.gpioint = gpioint;
Expand Down Expand Up @@ -1255,7 +1282,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)

acpi_gpiochip_request_regions(acpi_gpio);
acpi_gpiochip_scan_gpios(acpi_gpio);
acpi_walk_dep_device_list(handle);
acpi_dev_flag_dependency_met(handle);
}

void acpi_gpiochip_remove(struct gpio_chip *chip)
Expand Down
18 changes: 1 addition & 17 deletions drivers/i2c/i2c-core-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)
if (!handle)
return;

acpi_walk_dep_device_list(handle);
acpi_dev_flag_dependency_met(handle);
}

static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {
Expand Down Expand Up @@ -497,22 +497,6 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
}
EXPORT_SYMBOL_GPL(i2c_acpi_new_device);

/**
* i2c_acpi_dev_name - Construct i2c device name for devs sourced from ACPI
* @adev: ACPI device to construct the name for
*
* Constructs the name of an i2c device matching the format used by
* i2c_dev_set_name() to allow users to refer to an i2c device by name even
* before they have been instantiated.
*
* The caller is responsible for freeing the returned pointer.
*/
char *i2c_acpi_dev_name(struct acpi_device *adev)
{
return kasprintf(GFP_KERNEL, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev));
}
EXPORT_SYMBOL_GPL(i2c_acpi_dev_name);

#ifdef CONFIG_ACPI_I2C_OPREGION
static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
u8 cmd, u8 *data, u8 data_len)
Expand Down
Loading