Commit e3f44407 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'acpi-scan' and 'acpi-processor'

Merge ACPI device enumeration updates and ACPI processor driver updates
for 6.8-rc1:

 - Add CSI-2 and DisCo for Imaging support to the ACPI device
   enumeration code (Sakari Ailus, Rafael J. Wysocki).

 - Adjust the cpufreq thermal reduction algorithm in the ACPI processor
   driver for Tegra241 (Srikar Srimath Tirumala, Arnd Bergmann).

 - Make acpi_proc_quirk_mwait_check() x86-specific (Rafael J. Wysocki).

* acpi-scan:
  ACPI: scan: Fix an error message in DisCo for Imaging support
  ACPI: property: Replicate DT-aligned u32 properties from DisCo for Imaging
  ACPI: property: Dig "rotation" property for devices with CSI2 _CRS
  ACPI: scan: Extract MIPI DisCo for Imaging data into swnodes
  device property: Add SOFTWARE_NODE() macro for defining software nodes
  ACPI: scan: Extract _CRS CSI-2 connection information into swnodes
  ACPI: scan: Extract CSI-2 connection graph from _CRS
  ACPI: property: Support using strings in reference properties

* acpi-processor:
  ACPI: arm64: export acpi_arch_thermal_cpufreq_pctg()
  ACPI: processor: reduce CPUFREQ thermal reduction pctg for Tegra241
  ACPI: processor: Provide empty stub of acpi_proc_quirk_mwait_check()
...@@ -37,7 +37,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o ...@@ -37,7 +37,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o
# ACPI Bus and Device Drivers # ACPI Bus and Device Drivers
# #
acpi-y += bus.o glue.o acpi-y += bus.o glue.o
acpi-y += scan.o acpi-y += scan.o mipi-disco-img.o
acpi-y += resource.o acpi-y += resource.o
acpi-y += acpi_processor.o acpi-y += acpi_processor.o
acpi-y += processor_core.o acpi-y += processor_core.o
......
...@@ -5,3 +5,4 @@ obj-$(CONFIG_ACPI_GTDT) += gtdt.o ...@@ -5,3 +5,4 @@ obj-$(CONFIG_ACPI_GTDT) += gtdt.o
obj-$(CONFIG_ACPI_APMT) += apmt.o obj-$(CONFIG_ACPI_APMT) += apmt.o
obj-$(CONFIG_ARM_AMBA) += amba.o obj-$(CONFIG_ARM_AMBA) += amba.o
obj-y += dma.o init.o obj-y += dma.o init.o
obj-y += thermal_cpufreq.o
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/acpi.h>
#include <linux/export.h>
#include "../internal.h"
#define SMCCC_SOC_ID_T241 0x036b0241
int acpi_arch_thermal_cpufreq_pctg(void)
{
s32 soc_id = arm_smccc_get_soc_id_version();
/*
* Check JEP106 code for NVIDIA Tegra241 chip (036b:0241) and
* reduce the CPUFREQ Thermal reduction percentage to 5%.
*/
if (soc_id == SMCCC_SOC_ID_T241)
return 5;
return 0;
}
EXPORT_SYMBOL_GPL(acpi_arch_thermal_cpufreq_pctg);
...@@ -85,6 +85,15 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); ...@@ -85,6 +85,15 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context); acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context);
void acpi_scan_table_notify(void); void acpi_scan_table_notify(void);
#ifdef CONFIG_ARM64
int acpi_arch_thermal_cpufreq_pctg(void);
#else
static inline int acpi_arch_thermal_cpufreq_pctg(void)
{
return 0;
}
#endif
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Device Node Initialization / Removal Device Node Initialization / Removal
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -148,8 +157,11 @@ int acpi_wakeup_device_init(void); ...@@ -148,8 +157,11 @@ int acpi_wakeup_device_init(void);
#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
void acpi_early_processor_control_setup(void); void acpi_early_processor_control_setup(void);
void acpi_early_processor_set_pdc(void); void acpi_early_processor_set_pdc(void);
#ifdef CONFIG_X86
void acpi_proc_quirk_mwait_check(void); void acpi_proc_quirk_mwait_check(void);
#else
static inline void acpi_proc_quirk_mwait_check(void) {}
#endif
bool processor_physically_present(acpi_handle handle); bool processor_physically_present(acpi_handle handle);
#else #else
static inline void acpi_early_processor_control_setup(void) {} static inline void acpi_early_processor_control_setup(void) {}
...@@ -276,4 +288,13 @@ void acpi_init_lpit(void); ...@@ -276,4 +288,13 @@ void acpi_init_lpit(void);
static inline void acpi_init_lpit(void) { } static inline void acpi_init_lpit(void) { }
#endif #endif
/*--------------------------------------------------------------------------
ACPI _CRS CSI-2 and MIPI DisCo for Imaging
-------------------------------------------------------------------------- */
void acpi_mipi_check_crs_csi2(acpi_handle handle);
void acpi_mipi_scan_crs_csi2(void);
void acpi_mipi_init_crs_csi2_swnodes(void);
void acpi_mipi_crs_csi2_cleanup(void);
#endif /* _ACPI_INTERNAL_H_ */ #endif /* _ACPI_INTERNAL_H_ */
This diff is collapsed.
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <acpi/processor.h> #include <acpi/processor.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include "internal.h"
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
/* If a passive cooling situation is detected, primarily CPUfreq is used, as it /* If a passive cooling situation is detected, primarily CPUfreq is used, as it
...@@ -26,12 +28,21 @@ ...@@ -26,12 +28,21 @@
*/ */
#define CPUFREQ_THERMAL_MIN_STEP 0 #define CPUFREQ_THERMAL_MIN_STEP 0
#define CPUFREQ_THERMAL_MAX_STEP 3
static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg); static int cpufreq_thermal_max_step __read_mostly = 3;
/*
* Minimum throttle percentage for processor_thermal cooling device.
* The processor_thermal driver uses it to calculate the percentage amount by
* which cpu frequency must be reduced for each cooling state. This is also used
* to calculate the maximum number of throttling steps or cooling states.
*/
static int cpufreq_thermal_reduction_pctg __read_mostly = 20;
#define reduction_pctg(cpu) \ static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_step);
per_cpu(cpufreq_thermal_reduction_pctg, phys_package_first_cpu(cpu))
#define reduction_step(cpu) \
per_cpu(cpufreq_thermal_reduction_step, phys_package_first_cpu(cpu))
/* /*
* Emulate "per package data" using per cpu data (which should really be * Emulate "per package data" using per cpu data (which should really be
...@@ -71,7 +82,7 @@ static int cpufreq_get_max_state(unsigned int cpu) ...@@ -71,7 +82,7 @@ static int cpufreq_get_max_state(unsigned int cpu)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return 0; return 0;
return CPUFREQ_THERMAL_MAX_STEP; return cpufreq_thermal_max_step;
} }
static int cpufreq_get_cur_state(unsigned int cpu) static int cpufreq_get_cur_state(unsigned int cpu)
...@@ -79,7 +90,7 @@ static int cpufreq_get_cur_state(unsigned int cpu) ...@@ -79,7 +90,7 @@ static int cpufreq_get_cur_state(unsigned int cpu)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return 0; return 0;
return reduction_pctg(cpu); return reduction_step(cpu);
} }
static int cpufreq_set_cur_state(unsigned int cpu, int state) static int cpufreq_set_cur_state(unsigned int cpu, int state)
...@@ -92,7 +103,7 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) ...@@ -92,7 +103,7 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return 0; return 0;
reduction_pctg(cpu) = state; reduction_step(cpu) = state;
/* /*
* Update all the CPUs in the same package because they all * Update all the CPUs in the same package because they all
...@@ -113,7 +124,8 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) ...@@ -113,7 +124,8 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
if (!policy) if (!policy)
return -EINVAL; return -EINVAL;
max_freq = (policy->cpuinfo.max_freq * (100 - reduction_pctg(i) * 20)) / 100; max_freq = (policy->cpuinfo.max_freq *
(100 - reduction_step(i) * cpufreq_thermal_reduction_pctg)) / 100;
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
...@@ -126,10 +138,29 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) ...@@ -126,10 +138,29 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
return 0; return 0;
} }
static void acpi_thermal_cpufreq_config(void)
{
int cpufreq_pctg = acpi_arch_thermal_cpufreq_pctg();
if (!cpufreq_pctg)
return;
cpufreq_thermal_reduction_pctg = cpufreq_pctg;
/*
* Derive the MAX_STEP from minimum throttle percentage so that the reduction
* percentage doesn't end up becoming negative. Also, cap the MAX_STEP so that
* the CPU performance doesn't become 0.
*/
cpufreq_thermal_max_step = (100 / cpufreq_pctg) - 2;
}
void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy) void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy)
{ {
unsigned int cpu; unsigned int cpu;
acpi_thermal_cpufreq_config();
for_each_cpu(cpu, policy->related_cpus) { for_each_cpu(cpu, policy->related_cpus) {
struct acpi_processor *pr = per_cpu(processors, cpu); struct acpi_processor *pr = per_cpu(processors, cpu);
int ret; int ret;
...@@ -190,7 +221,7 @@ static int acpi_processor_max_state(struct acpi_processor *pr) ...@@ -190,7 +221,7 @@ static int acpi_processor_max_state(struct acpi_processor *pr)
/* /*
* There exists four states according to * There exists four states according to
* cpufreq_thermal_reduction_pctg. 0, 1, 2, 3 * cpufreq_thermal_reduction_step. 0, 1, 2, 3
*/ */
max_state += cpufreq_get_max_state(pr->id); max_state += cpufreq_get_max_state(pr->id);
if (pr->flags.throttling) if (pr->flags.throttling)
......
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
/* /*
* ACPI device specific properties support. * ACPI device specific properties support.
* *
* Copyright (C) 2014, Intel Corporation * Copyright (C) 2014 - 2023, Intel Corporation
* All rights reserved. * All rights reserved.
* *
* Authors: Mika Westerberg <mika.westerberg@linux.intel.com> * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
* Darren Hart <dvhart@linux.intel.com> * Darren Hart <dvhart@linux.intel.com>
* Rafael J. Wysocki <rafael.j.wysocki@intel.com> * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
* Sakari Ailus <sakari.ailus@linux.intel.com>
*/ */
#define pr_fmt(fmt) "ACPI: " fmt
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/export.h> #include <linux/export.h>
...@@ -800,28 +803,16 @@ static int acpi_get_ref_args(struct fwnode_reference_args *args, ...@@ -800,28 +803,16 @@ static int acpi_get_ref_args(struct fwnode_reference_args *args,
{ {
u32 nargs = 0, i; u32 nargs = 0, i;
/*
* Find the referred data extension node under the
* referred device node.
*/
for (; *element < end && (*element)->type == ACPI_TYPE_STRING;
(*element)++) {
const char *child_name = (*element)->string.pointer;
ref_fwnode = acpi_fwnode_get_named_child_node(ref_fwnode, child_name);
if (!ref_fwnode)
return -EINVAL;
}
/* /*
* Assume the following integer elements are all args. Stop counting on * Assume the following integer elements are all args. Stop counting on
* the first reference or end of the package arguments. In case of * the first reference (possibly represented as a string) or end of the
* neither reference, nor integer, return an error, we can't parse it. * package arguments. In case of neither reference, nor integer, return
* an error, we can't parse it.
*/ */
for (i = 0; (*element) + i < end && i < num_args; i++) { for (i = 0; (*element) + i < end && i < num_args; i++) {
acpi_object_type type = (*element)[i].type; acpi_object_type type = (*element)[i].type;
if (type == ACPI_TYPE_LOCAL_REFERENCE) if (type == ACPI_TYPE_LOCAL_REFERENCE || type == ACPI_TYPE_STRING)
break; break;
if (type == ACPI_TYPE_INTEGER) if (type == ACPI_TYPE_INTEGER)
...@@ -845,6 +836,44 @@ static int acpi_get_ref_args(struct fwnode_reference_args *args, ...@@ -845,6 +836,44 @@ static int acpi_get_ref_args(struct fwnode_reference_args *args,
return 0; return 0;
} }
static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *fwnode,
const char *refstring)
{
acpi_handle scope, handle;
struct acpi_data_node *dn;
struct acpi_device *device;
acpi_status status;
if (is_acpi_device_node(fwnode)) {
scope = to_acpi_device_node(fwnode)->handle;
} else if (is_acpi_data_node(fwnode)) {
scope = to_acpi_data_node(fwnode)->handle;
} else {
pr_debug("Bad node type for node %pfw\n", fwnode);
return NULL;
}
status = acpi_get_handle(scope, refstring, &handle);
if (ACPI_FAILURE(status)) {
acpi_handle_debug(scope, "Unable to get an ACPI handle for %s\n",
refstring);
return NULL;
}
device = acpi_fetch_acpi_dev(handle);
if (device)
return acpi_fwnode_handle(device);
status = acpi_get_data_full(handle, acpi_nondev_subnode_tag,
(void **)&dn, NULL);
if (ACPI_FAILURE(status) || !dn) {
acpi_handle_debug(handle, "Subnode not found\n");
return NULL;
}
return &dn->fwnode;
}
/** /**
* __acpi_node_get_property_reference - returns handle to the referenced object * __acpi_node_get_property_reference - returns handle to the referenced object
* @fwnode: Firmware node to get the property from * @fwnode: Firmware node to get the property from
...@@ -887,6 +916,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -887,6 +916,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const union acpi_object *element, *end; const union acpi_object *element, *end;
const union acpi_object *obj; const union acpi_object *obj;
const struct acpi_device_data *data; const struct acpi_device_data *data;
struct fwnode_handle *ref_fwnode;
struct acpi_device *device; struct acpi_device *device;
int ret, idx = 0; int ret, idx = 0;
...@@ -910,16 +940,30 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -910,16 +940,30 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
args->fwnode = acpi_fwnode_handle(device); args->fwnode = acpi_fwnode_handle(device);
args->nargs = 0; args->nargs = 0;
return 0;
case ACPI_TYPE_STRING:
if (index)
return -ENOENT;
ref_fwnode = acpi_parse_string_ref(fwnode, obj->string.pointer);
if (!ref_fwnode)
return -EINVAL;
args->fwnode = ref_fwnode;
args->nargs = 0;
return 0; return 0;
case ACPI_TYPE_PACKAGE: case ACPI_TYPE_PACKAGE:
/* /*
* If it is not a single reference, then it is a package of * If it is not a single reference, then it is a package of
* references followed by number of ints as follows: * references, followed by number of ints as follows:
* *
* Package () { REF, INT, REF, INT, INT } * Package () { REF, INT, REF, INT, INT }
* *
* The index argument is then used to determine which reference * Here, REF may be either a local reference or a string. The
* the caller wants (along with the arguments). * index argument is then used to determine which reference the
* caller wants (along with the arguments).
*/ */
break; break;
default: default:
...@@ -950,6 +994,24 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -950,6 +994,24 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
if (idx == index) if (idx == index)
return 0; return 0;
break;
case ACPI_TYPE_STRING:
ref_fwnode = acpi_parse_string_ref(fwnode,
element->string.pointer);
if (!ref_fwnode)
return -EINVAL;
element++;
ret = acpi_get_ref_args(idx == index ? args : NULL,
ref_fwnode, &element, end,
num_args);
if (ret < 0)
return ret;
if (idx == index)
return 0;
break; break;
case ACPI_TYPE_INTEGER: case ACPI_TYPE_INTEGER:
if (idx == index) if (idx == index)
......
...@@ -1981,7 +1981,7 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) ...@@ -1981,7 +1981,7 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
} }
} }
static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep) static u32 acpi_scan_check_dep(acpi_handle handle)
{ {
struct acpi_handle_list dep_devices; struct acpi_handle_list dep_devices;
acpi_status status; acpi_status status;
...@@ -1994,8 +1994,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep) ...@@ -1994,8 +1994,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
* 2. ACPI nodes describing USB ports. * 2. ACPI nodes describing USB ports.
* Still, checking for _HID catches more then just these cases ... * Still, checking for _HID catches more then just these cases ...
*/ */
if (!check_dep || !acpi_has_method(handle, "_DEP") || if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID"))
!acpi_has_method(handle, "_HID"))
return 0; return 0;
status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices); status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
...@@ -2041,7 +2040,13 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep) ...@@ -2041,7 +2040,13 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
return count; return count;
} }
static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, static acpi_status acpi_scan_check_crs_csi2_cb(acpi_handle handle, u32 a, void *b, void **c)
{
acpi_mipi_check_crs_csi2(handle);
return AE_OK;
}
static acpi_status acpi_bus_check_add(acpi_handle handle, bool first_pass,
struct acpi_device **adev_p) struct acpi_device **adev_p)
{ {
struct acpi_device *device = acpi_fetch_acpi_dev(handle); struct acpi_device *device = acpi_fetch_acpi_dev(handle);
...@@ -2059,9 +2064,25 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, ...@@ -2059,9 +2064,25 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
if (acpi_device_should_be_hidden(handle)) if (acpi_device_should_be_hidden(handle))
return AE_OK; return AE_OK;
if (first_pass) {
acpi_mipi_check_crs_csi2(handle);
/* Bail out if there are dependencies. */ /* Bail out if there are dependencies. */
if (acpi_scan_check_dep(handle, check_dep) > 0) if (acpi_scan_check_dep(handle) > 0) {
/*
* The entire CSI-2 connection graph needs to be
* extracted before any drivers or scan handlers
* are bound to struct device objects, so scan
* _CRS CSI-2 resource descriptors for all
* devices below the current handle.
*/
acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
ACPI_UINT32_MAX,
acpi_scan_check_crs_csi2_cb,
NULL, NULL, NULL);
return AE_CTRL_DEPTH; return AE_CTRL_DEPTH;
}
}
fallthrough; fallthrough;
case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */ case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */
...@@ -2084,10 +2105,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, ...@@ -2084,10 +2105,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
} }
/* /*
* If check_dep is true at this point, the device has no dependencies, * If first_pass is true at this point, the device has no dependencies,
* or the creation of the device object would have been postponed above. * or the creation of the device object would have been postponed above.
*/ */
acpi_add_single_object(&device, handle, type, !check_dep); acpi_add_single_object(&device, handle, type, !first_pass);
if (!device) if (!device)
return AE_CTRL_DEPTH; return AE_CTRL_DEPTH;
...@@ -2431,6 +2452,13 @@ static void acpi_scan_postponed_branch(acpi_handle handle) ...@@ -2431,6 +2452,13 @@ static void acpi_scan_postponed_branch(acpi_handle handle)
acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
acpi_bus_check_add_2, NULL, NULL, (void **)&adev); acpi_bus_check_add_2, NULL, NULL, (void **)&adev);
/*
* Populate the ACPI _CRS CSI-2 software nodes for the ACPI devices that
* have been added above.
*/
acpi_mipi_init_crs_csi2_swnodes();
acpi_bus_attach(adev, NULL); acpi_bus_attach(adev, NULL);
} }
...@@ -2499,12 +2527,22 @@ int acpi_bus_scan(acpi_handle handle) ...@@ -2499,12 +2527,22 @@ int acpi_bus_scan(acpi_handle handle)
if (!device) if (!device)
return -ENODEV; return -ENODEV;
/*
* Set up ACPI _CRS CSI-2 software nodes using information extracted
* from the _CRS CSI-2 resource descriptors during the ACPI namespace
* walk above and MIPI DisCo for Imaging device properties.
*/
acpi_mipi_scan_crs_csi2();
acpi_mipi_init_crs_csi2_swnodes();
acpi_bus_attach(device, (void *)true); acpi_bus_attach(device, (void *)true);
/* Pass 2: Enumerate all of the remaining devices. */ /* Pass 2: Enumerate all of the remaining devices. */
acpi_scan_postponed(); acpi_scan_postponed();
acpi_mipi_crs_csi2_cleanup();
return 0; return 0;
} }
EXPORT_SYMBOL(acpi_bus_scan); EXPORT_SYMBOL(acpi_bus_scan);
......
...@@ -366,6 +366,98 @@ struct acpi_device_data { ...@@ -366,6 +366,98 @@ struct acpi_device_data {
struct acpi_gpio_mapping; struct acpi_gpio_mapping;
#define ACPI_DEVICE_SWNODE_ROOT 0
/*
* The maximum expected number of CSI-2 data lanes.
*
* This number is not expected to ever have to be equal to or greater than the
* number of bits in an unsigned long variable, but if it needs to be increased
* above that limit, code will need to be adjusted accordingly.
*/
#define ACPI_DEVICE_CSI2_DATA_LANES 8
#define ACPI_DEVICE_SWNODE_PORT_NAME_LENGTH 8
enum acpi_device_swnode_dev_props {
ACPI_DEVICE_SWNODE_DEV_ROTATION,
ACPI_DEVICE_SWNODE_DEV_CLOCK_FREQUENCY,
ACPI_DEVICE_SWNODE_DEV_LED_MAX_MICROAMP,
ACPI_DEVICE_SWNODE_DEV_FLASH_MAX_MICROAMP,
ACPI_DEVICE_SWNODE_DEV_FLASH_MAX_TIMEOUT_US,
ACPI_DEVICE_SWNODE_DEV_NUM_OF,
ACPI_DEVICE_SWNODE_DEV_NUM_ENTRIES
};
enum acpi_device_swnode_port_props {
ACPI_DEVICE_SWNODE_PORT_REG,
ACPI_DEVICE_SWNODE_PORT_NUM_OF,
ACPI_DEVICE_SWNODE_PORT_NUM_ENTRIES
};
enum acpi_device_swnode_ep_props {
ACPI_DEVICE_SWNODE_EP_REMOTE_EP,
ACPI_DEVICE_SWNODE_EP_BUS_TYPE,
ACPI_DEVICE_SWNODE_EP_REG,
ACPI_DEVICE_SWNODE_EP_CLOCK_LANES,
ACPI_DEVICE_SWNODE_EP_DATA_LANES,
ACPI_DEVICE_SWNODE_EP_LANE_POLARITIES,
/* TX only */
ACPI_DEVICE_SWNODE_EP_LINK_FREQUENCIES,
ACPI_DEVICE_SWNODE_EP_NUM_OF,
ACPI_DEVICE_SWNODE_EP_NUM_ENTRIES
};
/*
* Each device has a root software node plus two times as many nodes as the
* number of CSI-2 ports.
*/
#define ACPI_DEVICE_SWNODE_PORT(port) (2 * (port) + 1)
#define ACPI_DEVICE_SWNODE_EP(endpoint) \
(ACPI_DEVICE_SWNODE_PORT(endpoint) + 1)
/**
* struct acpi_device_software_node_port - MIPI DisCo for Imaging CSI-2 port
* @port_name: Port name.
* @data_lanes: "data-lanes" property values.
* @lane_polarities: "lane-polarities" property values.
* @link_frequencies: "link_frequencies" property values.
* @port_nr: Port number.
* @crs_crs2_local: _CRS CSI2 record present (i.e. this is a transmitter one).
* @port_props: Port properties.
* @ep_props: Endpoint properties.
* @remote_ep: Reference to the remote endpoint.
*/
struct acpi_device_software_node_port {
char port_name[ACPI_DEVICE_SWNODE_PORT_NAME_LENGTH + 1];
u32 data_lanes[ACPI_DEVICE_CSI2_DATA_LANES];
u32 lane_polarities[ACPI_DEVICE_CSI2_DATA_LANES + 1 /* clock lane */];
u64 link_frequencies[ACPI_DEVICE_CSI2_DATA_LANES];
unsigned int port_nr;
bool crs_csi2_local;
struct property_entry port_props[ACPI_DEVICE_SWNODE_PORT_NUM_ENTRIES];
struct property_entry ep_props[ACPI_DEVICE_SWNODE_EP_NUM_ENTRIES];
struct software_node_ref_args remote_ep[1];
};
/**
* struct acpi_device_software_nodes - Software nodes for an ACPI device
* @dev_props: Device properties.
* @nodes: Software nodes for root as well as ports and endpoints.
* @nodeprts: Array of software node pointers, for (un)registering them.
* @ports: Information related to each port and endpoint within a port.
* @num_ports: The number of ports.
*/
struct acpi_device_software_nodes {
struct property_entry dev_props[ACPI_DEVICE_SWNODE_DEV_NUM_ENTRIES];
struct software_node *nodes;
const struct software_node **nodeptrs;
struct acpi_device_software_node_port *ports;
unsigned int num_ports;
};
/* Device */ /* Device */
struct acpi_device { struct acpi_device {
u32 pld_crc; u32 pld_crc;
...@@ -384,6 +476,7 @@ struct acpi_device { ...@@ -384,6 +476,7 @@ struct acpi_device {
struct acpi_device_data data; struct acpi_device_data data;
struct acpi_scan_handler *handler; struct acpi_scan_handler *handler;
struct acpi_hotplug_context *hp; struct acpi_hotplug_context *hp;
struct acpi_device_software_nodes *swnodes;
const struct acpi_gpio_mapping *driver_gpios; const struct acpi_gpio_mapping *driver_gpios;
void *driver_data; void *driver_data;
struct device dev; struct device dev;
......
...@@ -489,6 +489,13 @@ struct software_node { ...@@ -489,6 +489,13 @@ struct software_node {
const struct property_entry *properties; const struct property_entry *properties;
}; };
#define SOFTWARE_NODE(_name_, _properties_, _parent_) \
(struct software_node) { \
.name = _name_, \
.properties = _properties_, \
.parent = _parent_, \
}
bool is_software_node(const struct fwnode_handle *fwnode); bool is_software_node(const struct fwnode_handle *fwnode);
const struct software_node * const struct software_node *
to_software_node(const struct fwnode_handle *fwnode); to_software_node(const struct fwnode_handle *fwnode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment