當前位置: 首頁>>代碼示例>>C++>>正文


C++ ACPI_COMPANION函數代碼示例

本文整理匯總了C++中ACPI_COMPANION函數的典型用法代碼示例。如果您正苦於以下問題:C++ ACPI_COMPANION函數的具體用法?C++ ACPI_COMPANION怎麽用?C++ ACPI_COMPANION使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ACPI_COMPANION函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: acpi_dev_pm_attach

/**
 * acpi_dev_pm_attach - Prepare device for ACPI power management.
 * @dev: Device to prepare.
 * @power_on: Whether or not to power on the device.
 *
 * If @dev has a valid ACPI handle that has a valid struct acpi_device object
 * attached to it, install a wakeup notification handler for the device and
 * add it to the general ACPI PM domain.  If @power_on is set, the device will
 * be put into the ACPI D0 state before the function returns.
 *
 * This assumes that the @dev's bus type uses generic power management callbacks
 * (or doesn't use any power management callbacks at all).
 *
 * Callers must ensure proper synchronization of this function with power
 * management callbacks.
 */
int acpi_dev_pm_attach(struct device *dev, bool power_on)
{
	struct acpi_device *adev = ACPI_COMPANION(dev);

	if (!adev)
		return -ENODEV;

	if (dev->pm_domain)
		return -EEXIST;

	/*
	 * Only attach the power domain to the first device if the
	 * companion is shared by multiple. This is to prevent doing power
	 * management twice.
	 */
	if (!acpi_device_is_first_physical_node(adev, dev))
		return -EBUSY;

	acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
	dev->pm_domain = &acpi_general_pm_domain;
	if (power_on) {
		acpi_dev_pm_full_power(adev);
		acpi_device_wakeup(adev, ACPI_STATE_S0, false);
	}

	return 0;
}
開發者ID:magarto,項目名稱:linux-rpi-grsecurity,代碼行數:43,代碼來源:device_pm.c

示例2: snd_byt_rt5651_mc_add_amp_en_gpio_mapping

static void snd_byt_rt5651_mc_add_amp_en_gpio_mapping(struct device *codec)
{
	struct byt_rt5651_acpi_resource_data data = { 0, -1 };
	LIST_HEAD(resources);
	int ret;

	ret = acpi_dev_get_resources(ACPI_COMPANION(codec), &resources,
				     snd_byt_rt5651_acpi_resource, &data);
	if (ret < 0) {
		dev_warn(codec, "Failed to get ACPI resources, not adding external amplifier GPIO mapping\n");
		return;
	}

	/* All info we need is gathered during the walk */
	acpi_dev_free_resource_list(&resources);

	switch (data.gpio_int_idx) {
	case 0:
		devm_acpi_dev_add_driver_gpios(codec, byt_rt5651_amp_en_second);
		break;
	case 1:
		devm_acpi_dev_add_driver_gpios(codec, byt_rt5651_amp_en_first);
		break;
	default:
		dev_warn(codec, "Unknown GpioInt index %d, not adding external amplifier GPIO mapping\n",
			 data.gpio_int_idx);
	}
}
開發者ID:markus-oberhumer,項目名稱:linux,代碼行數:28,代碼來源:bytcr_rt5651.c

示例3: pch_wpt_add_acpi_psv_trip

/*
 * On some platforms, there is a companion ACPI device, which adds
 * passive trip temperature using _PSV method. There is no specific
 * passive temperature setting in MMIO interface of this PCI device.
 */
static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
				      int *nr_trips)
{
	struct acpi_device *adev;

	ptd->psv_trip_id = -1;

	adev = ACPI_COMPANION(&ptd->pdev->dev);
	if (adev) {
		unsigned long long r;
		acpi_status status;

		status = acpi_evaluate_integer(adev->handle, "_PSV", NULL,
					       &r);
		if (ACPI_SUCCESS(status)) {
			unsigned long trip_temp;

			trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r);
			if (trip_temp) {
				ptd->psv_temp = trip_temp;
				ptd->psv_trip_id = *nr_trips;
				++(*nr_trips);
			}
		}
	}
}
開發者ID:AlexShiLucky,項目名稱:linux,代碼行數:31,代碼來源:intel_pch_thermal.c

示例4: acpi_dev_suspend_late

/**
 * acpi_dev_suspend_late - Put device into a low-power state using ACPI.
 * @dev: Device to put into a low-power state.
 *
 * Put the given device into a low-power state during system transition to a
 * sleep state using the standard ACPI mechanism.  Set up system wakeup if
 * desired, choose the state to put the device into (this checks if system
 * wakeup is expected to work too), and set the power state of the device.
 */
int acpi_dev_suspend_late(struct device *dev)
{
	struct acpi_device *adev = ACPI_COMPANION(dev);
	u32 target_state;
	bool wakeup;
	bool can_wakeup;
	int error;

	if (!adev)
		return 0;

	target_state = acpi_target_system_state();
	wakeup = device_may_wakeup(dev);
	can_wakeup = acpi_device_can_wakeup(adev);

	if (can_wakeup) {
		error = __acpi_device_sleep_wake(adev, target_state, wakeup);
		if (wakeup && error)
			return error;
	} else if (wakeup) {
		dev_warn(dev,
			 "device is not wakeup-capable, not enabling wakeup\n");
	}

	error = acpi_dev_pm_low_power(dev, adev, target_state);
	if (error && can_wakeup)
		__acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false);

	return error;
}
開發者ID:lihp1603,項目名稱:firefly-3.14-kernel,代碼行數:39,代碼來源:device_pm.c

示例5: st33zp24_spi_acpi_request_resources

static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev)
{
	struct tpm_chip *chip = spi_get_drvdata(spi_dev);
	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
	struct st33zp24_spi_phy *phy = tpm_dev->phy_id;
	struct gpio_desc *gpiod_lpcpd;
	struct device *dev = &spi_dev->dev;
	int ret;

	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios);
	if (ret)
		return ret;

	/* Get LPCPD GPIO from ACPI */
	gpiod_lpcpd = devm_gpiod_get(dev, "lpcpd", GPIOD_OUT_HIGH);
	if (IS_ERR(gpiod_lpcpd)) {
		dev_err(dev, "Failed to retrieve lpcpd-gpios from acpi.\n");
		phy->io_lpcpd = -1;
		/*
		 * lpcpd pin is not specified. This is not an issue as
		 * power management can be also managed by TPM specific
		 * commands. So leave with a success status code.
		 */
		return 0;
	}

	phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd);

	return 0;
}
開發者ID:asmalldev,項目名稱:linux,代碼行數:30,代碼來源:spi.c

示例6: acpi_dev_pm_attach

/**
 * acpi_dev_pm_attach - Prepare device for ACPI power management.
 * @dev: Device to prepare.
 * @power_on: Whether or not to power on the device.
 *
 * If @dev has a valid ACPI handle that has a valid struct acpi_device object
 * attached to it, install a wakeup notification handler for the device and
 * add it to the general ACPI PM domain.  If @power_on is set, the device will
 * be put into the ACPI D0 state before the function returns.
 *
 * This assumes that the @dev's bus type uses generic power management callbacks
 * (or doesn't use any power management callbacks at all).
 *
 * Callers must ensure proper synchronization of this function with power
 * management callbacks.
 */
int acpi_dev_pm_attach(struct device *dev, bool power_on)
{
	struct acpi_device *adev = ACPI_COMPANION(dev);

	if (!adev)
		return -ENODEV;

	if (!strcmp(dev_name(dev), "80860F28:00")) {
		dev_info(dev, "Skipping ACPI power domain attach\n");
		return -ENODEV;
	}

	if (dev->pm_domain)
		return -EEXIST;

	acpi_add_pm_notifier(adev, acpi_wakeup_device, dev);
	dev->pm_domain = &acpi_general_pm_domain;
	if (power_on) {
		acpi_dev_pm_full_power(adev);
		__acpi_device_run_wake(adev, false);
	}

	dev->pm_domain->detach = acpi_dev_pm_detach;
	return 0;
}
開發者ID:lihp1603,項目名稱:firefly-3.14-kernel,代碼行數:41,代碼來源:device_pm.c

示例7: device_property_present

/**
 * device_property_present - check if a property of a device is present
 * @dev: Device whose property is being checked
 * @propname: Name of the property
 *
 * Check if property @propname is present in the device firmware description.
 */
bool device_property_present(struct device *dev, const char *propname)
{
	if (IS_ENABLED(CONFIG_OF) && dev->of_node)
		return of_property_read_bool(dev->of_node, propname);

	return !acpi_dev_prop_get(ACPI_COMPANION(dev), propname, NULL);
}
開發者ID:168519,項目名稱:linux,代碼行數:14,代碼來源:property.c

示例8:

void *lm3554_platform_data_func(struct i2c_client *client)
{
	static struct lm3554_platform_data platform_data;

	if (ACPI_COMPANION(&client->dev)) {
		platform_data.gpio_reset  =
			desc_to_gpio(gpiod_get_index(&(client->dev), "lm3554_gpio2", 2));
		platform_data.gpio_strobe =
			desc_to_gpio(gpiod_get_index(&(client->dev), "lm3554_gpio0", 0));
		platform_data.gpio_torch  =
			desc_to_gpio(gpiod_get_index(&(client->dev), "lm3554_gpio1", 1));
	}else {
		platform_data.gpio_reset = -1;
		platform_data.gpio_strobe = -1;
		platform_data.gpio_torch = -1;
	}

	dev_info(&client->dev, "camera pdata: lm3554: reset: %d strobe %d torch %d\n",
		platform_data.gpio_reset, platform_data.gpio_strobe,
		platform_data.gpio_torch);

	/* Set to TX2 mode, then ENVM/TX2 pin is a power amplifier sync input:
	 * ENVM/TX pin asserted, flash forced into torch;
	 * ENVM/TX pin desserted, flash set back;
	 */
	platform_data.envm_tx2 = 1;
	platform_data.tx2_polarity = 0;

	/* set peak current limit to be 1000mA */
	platform_data.current_limit = 0;

	return &platform_data;
}
開發者ID:zenfone5,項目名稱:android_kernel_asus_T00F,代碼行數:33,代碼來源:lm3554.c

示例9: inv_mpu_process_acpi_config

static int inv_mpu_process_acpi_config(struct i2c_client *client,
				       unsigned short *primary_addr,
				       unsigned short *secondary_addr)
{
	const struct acpi_device_id *id;
	struct acpi_device *adev;
	u32 i2c_addr = 0;
	LIST_HEAD(resources);
	int ret;

	id = acpi_match_device(client->dev.driver->acpi_match_table,
			       &client->dev);
	if (!id)
		return -ENODEV;

	adev = ACPI_COMPANION(&client->dev);
	if (!adev)
		return -ENODEV;

	ret = acpi_dev_get_resources(adev, &resources,
				     acpi_i2c_check_resource, &i2c_addr);
	if (ret < 0)
		return ret;

	acpi_dev_free_resource_list(&resources);
	*primary_addr = i2c_addr & 0x0000ffff;
	*secondary_addr = (i2c_addr & 0xffff0000) >> 16;

	return 0;
}
開發者ID:513855417,項目名稱:linux,代碼行數:30,代碼來源:inv_mpu_acpi.c

示例10: ulpi_register

static int ulpi_register(struct device *dev, struct ulpi *ulpi)
{
	int ret;

	ulpi->dev.parent = dev; /* needed early for ops */
	ulpi->dev.bus = &ulpi_bus;
	ulpi->dev.type = &ulpi_dev_type;
	dev_set_name(&ulpi->dev, "%s.ulpi", dev_name(dev));

	ACPI_COMPANION_SET(&ulpi->dev, ACPI_COMPANION(dev));

	ret = ulpi_of_register(ulpi);
	if (ret)
		return ret;

	ret = ulpi_read_id(ulpi);
	if (ret)
		return ret;

	ret = device_register(&ulpi->dev);
	if (ret)
		return ret;

	dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n",
		ulpi->id.vendor, ulpi->id.product);

	return 0;
}
開發者ID:mkrufky,項目名稱:linux,代碼行數:28,代碼來源:ulpi.c

示例11: platform_get_irq

/**
 * platform_get_irq - get an IRQ for a device
 * @dev: platform device
 * @num: IRQ number index
 */
int platform_get_irq(struct platform_device *dev, unsigned int num)
{
#ifdef CONFIG_SPARC
	/* sparc does not have irqs represented as IORESOURCE_IRQ resources */
	if (!dev || num >= dev->archdata.num_irqs)
		return -ENXIO;
	return dev->archdata.irqs[num];
#else
	struct resource *r;
	if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
		int ret;

		ret = of_irq_get(dev->dev.of_node, num);
		if (ret > 0 || ret == -EPROBE_DEFER)
			return ret;
	}

	r = platform_get_resource(dev, IORESOURCE_IRQ, num);
	if (has_acpi_companion(&dev->dev)) {
		if (r && r->flags & IORESOURCE_DISABLED) {
			int ret;

			ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r);
			if (ret)
				return ret;
		}
	}

	/*
	 * The resources may pass trigger flags to the irqs that need
	 * to be set up. It so happens that the trigger flags for
	 * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
	 * settings.
	 */
	if (r && r->flags & IORESOURCE_BITS) {
		struct irq_data *irqd;

		irqd = irq_get_irq_data(r->start);
		if (!irqd)
			return -ENXIO;
		irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
	}

	if (r)
		return r->start;

	/*
	 * For the index 0 interrupt, allow falling back to GpioInt
	 * resources. While a device could have both Interrupt and GpioInt
	 * resources, making this fallback ambiguous, in many common cases
	 * the device will only expose one IRQ, and this fallback
	 * allows a common code path across either kind of resource.
	 */
	if (num == 0 && has_acpi_companion(&dev->dev))
		return acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);

	return -ENXIO;
#endif
}
開發者ID:avagin,項目名稱:linux,代碼行數:64,代碼來源:platform.c

示例12: device_property_read_string

/**
 * device_property_read_string - return a string property of a device
 * @dev: Device to get the property of
 * @propname: Name of the property
 * @val: The value is stored here
 *
 * Function reads property @propname from the device firmware description and
 * stores the value into @val if found. The value is checked to be a string.
 *
 * Return: %0 if the property was found (success),
 *	   %-EINVAL if given arguments are not valid,
 *	   %-ENODATA if the property does not have a value,
 *	   %-EPROTO or %-EILSEQ if the property type is not a string.
 */
int device_property_read_string(struct device *dev, const char *propname,
				const char **val)
{
	return IS_ENABLED(CONFIG_OF) && dev->of_node ?
		of_property_read_string(dev->of_node, propname, val) :
		acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
				   DEV_PROP_STRING, val, 1);
}
開發者ID:168519,項目名稱:linux,代碼行數:22,代碼來源:property.c

示例13: dwc3_pci_probe

static int dwc3_pci_probe(struct pci_dev *pci,
		const struct pci_device_id *id)
{
	struct resource		res[2];
	struct platform_device	*dwc3;
	int			ret;
	struct device		*dev = &pci->dev;

	ret = pcim_enable_device(pci);
	if (ret) {
		dev_err(dev, "failed to enable pci device\n");
		return -ENODEV;
	}

	pci_set_master(pci);

	dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
	if (!dwc3) {
		dev_err(dev, "couldn't allocate dwc3 device\n");
		return -ENOMEM;
	}

	memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));

	res[0].start	= pci_resource_start(pci, 0);
	res[0].end	= pci_resource_end(pci, 0);
	res[0].name	= "dwc_usb3";
	res[0].flags	= IORESOURCE_MEM;

	res[1].start	= pci->irq;
	res[1].name	= "dwc_usb3";
	res[1].flags	= IORESOURCE_IRQ;

	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
	if (ret) {
		dev_err(dev, "couldn't add resources to dwc3 device\n");
		return ret;
	}

	pci_set_drvdata(pci, dwc3);
	ret = dwc3_pci_quirks(pci);
	if (ret)
		goto err;

	dwc3->dev.parent = dev;
	ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev));

	ret = platform_device_add(dwc3);
	if (ret) {
		dev_err(dev, "failed to register dwc3 device\n");
		goto err;
	}

	return 0;
err:
	platform_device_put(dwc3);
	return ret;
}
開發者ID:Chong-Li,項目名稱:cse522,代碼行數:58,代碼來源:dwc3-pci.c

示例14: acpi_processor_start

static int acpi_processor_start(struct device *dev)
{
    struct acpi_device *device = ACPI_COMPANION(dev);

    if (!device)
        return -ENODEV;

    return __acpi_processor_start(device);
}
開發者ID:ChineseDr,項目名稱:linux,代碼行數:9,代碼來源:processor_driver.c

示例15: dwc3_pci_remove

static void dwc3_pci_remove(struct pci_dev *pci)
{
	struct dwc3_pci		*dwc = pci_get_drvdata(pci);

	device_init_wakeup(&pci->dev, false);
	pm_runtime_get(&pci->dev);
	acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
	platform_device_unregister(dwc->dwc3);
}
開發者ID:forgivemyheart,項目名稱:linux,代碼行數:9,代碼來源:dwc3-pci.c


注:本文中的ACPI_COMPANION函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。