Commit 476cc433 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'acpi-pci', 'acpi-irq' and 'acpi-assorted'

* acpi-pci:
  ACPI, PCI, irq: remove redundant check for null string pointer
  ACPI / PCI: Simplify acpi_penalize_isa_irq()
  ACPI, PCI, irq: remove interrupt number restriction
  ACPI, PCI, irq: remove interrupt count restriction

* acpi-irq:
  ACPI / spi: attach GPIO IRQ from ACPI description to SPI device
  ACPI / gpio: Add irq_type when a GPIO is used as an interrupt
  ACPI: Rename acpi_gsi_get_irq_type to acpi_dev_get_irq_type and export symbol

* acpi-assorted:
  ACPI / SBS: fix inconsistent indenting inside if statement
  ACPI: Fix build errors due objects compiled unconditionally
...@@ -8,13 +8,13 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT ...@@ -8,13 +8,13 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
# #
# ACPI Boot-Time Table Parsing # ACPI Boot-Time Table Parsing
# #
obj-y += tables.o obj-$(CONFIG_ACPI) += tables.o
obj-$(CONFIG_X86) += blacklist.o obj-$(CONFIG_X86) += blacklist.o
# #
# ACPI Core Subsystem (Interpreter) # ACPI Core Subsystem (Interpreter)
# #
obj-y += acpi.o \ obj-$(CONFIG_ACPI) += acpi.o \
acpica/ acpica/
# All the builtin files are in the "acpi." module_param namespace. # All the builtin files are in the "acpi." module_param namespace.
...@@ -66,10 +66,10 @@ obj-$(CONFIG_ACPI_FAN) += fan.o ...@@ -66,10 +66,10 @@ obj-$(CONFIG_ACPI_FAN) += fan.o
obj-$(CONFIG_ACPI_VIDEO) += video.o obj-$(CONFIG_ACPI_VIDEO) += video.o
obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o
obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
obj-y += container.o obj-$(CONFIG_ACPI) += container.o
obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o
obj-$(CONFIG_ACPI_NFIT) += nfit.o obj-$(CONFIG_ACPI_NFIT) += nfit.o
obj-y += acpi_memhotplug.o obj-$(CONFIG_ACPI) += acpi_memhotplug.o
obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o
obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_SBS) += sbshc.o obj-$(CONFIG_ACPI_SBS) += sbshc.o
......
...@@ -17,25 +17,6 @@ enum acpi_irq_model_id acpi_irq_model; ...@@ -17,25 +17,6 @@ enum acpi_irq_model_id acpi_irq_model;
static struct fwnode_handle *acpi_gsi_domain_id; static struct fwnode_handle *acpi_gsi_domain_id;
static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
{
switch (polarity) {
case ACPI_ACTIVE_LOW:
return trigger == ACPI_EDGE_SENSITIVE ?
IRQ_TYPE_EDGE_FALLING :
IRQ_TYPE_LEVEL_LOW;
case ACPI_ACTIVE_HIGH:
return trigger == ACPI_EDGE_SENSITIVE ?
IRQ_TYPE_EDGE_RISING :
IRQ_TYPE_LEVEL_HIGH;
case ACPI_ACTIVE_BOTH:
if (trigger == ACPI_EDGE_SENSITIVE)
return IRQ_TYPE_EDGE_BOTH;
default:
return IRQ_TYPE_NONE;
}
}
/** /**
* acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI * acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
* @gsi: GSI IRQ number to map * @gsi: GSI IRQ number to map
...@@ -82,7 +63,7 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, ...@@ -82,7 +63,7 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
fwspec.fwnode = acpi_gsi_domain_id; fwspec.fwnode = acpi_gsi_domain_id;
fwspec.param[0] = gsi; fwspec.param[0] = gsi;
fwspec.param[1] = acpi_gsi_get_irq_type(trigger, polarity); fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity);
fwspec.param_count = 2; fwspec.param_count = 2;
return irq_create_fwspec_mapping(&fwspec); return irq_create_fwspec_mapping(&fwspec);
......
...@@ -131,9 +131,6 @@ static void do_prt_fixups(struct acpi_prt_entry *entry, ...@@ -131,9 +131,6 @@ static void do_prt_fixups(struct acpi_prt_entry *entry,
quirk = &prt_quirks[i]; quirk = &prt_quirks[i];
/* All current quirks involve link devices, not GSIs */ /* All current quirks involve link devices, not GSIs */
if (!prt->source)
continue;
if (dmi_check_system(quirk->system) && if (dmi_check_system(quirk->system) &&
entry->id.segment == quirk->segment && entry->id.segment == quirk->segment &&
entry->id.bus == quirk->bus && entry->id.bus == quirk->bus &&
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
* Copyright (C) 2002 Dominik Brodowski <devel@brodo.de> * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
* *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* *
...@@ -67,12 +68,12 @@ static struct acpi_scan_handler pci_link_handler = { ...@@ -67,12 +68,12 @@ static struct acpi_scan_handler pci_link_handler = {
* later even the link is disable. Instead, we just repick the active irq * later even the link is disable. Instead, we just repick the active irq
*/ */
struct acpi_pci_link_irq { struct acpi_pci_link_irq {
u8 active; /* Current IRQ */ u32 active; /* Current IRQ */
u8 triggering; /* All IRQs */ u8 triggering; /* All IRQs */
u8 polarity; /* All IRQs */ u8 polarity; /* All IRQs */
u8 resource_type; u8 resource_type;
u8 possible_count; u8 possible_count;
u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; u32 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
u8 initialized:1; u8 initialized:1;
u8 reserved:7; u8 reserved:7;
}; };
...@@ -437,7 +438,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) ...@@ -437,7 +438,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
* enabled system. * enabled system.
*/ */
#define ACPI_MAX_IRQS 256
#define ACPI_MAX_ISA_IRQ 16 #define ACPI_MAX_ISA_IRQ 16
#define PIRQ_PENALTY_PCI_AVAILABLE (0) #define PIRQ_PENALTY_PCI_AVAILABLE (0)
...@@ -447,7 +447,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) ...@@ -447,7 +447,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
#define PIRQ_PENALTY_ISA_USED (16*16*16*16*16) #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
#define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16) #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
static int acpi_irq_penalty[ACPI_MAX_IRQS] = { static int acpi_irq_isa_penalty[ACPI_MAX_ISA_IRQ] = {
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
...@@ -464,9 +464,68 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = { ...@@ -464,9 +464,68 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */ PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */ PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */ PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
/* >IRQ15 */
}; };
struct irq_penalty_info {
int irq;
int penalty;
struct list_head node;
};
static LIST_HEAD(acpi_irq_penalty_list);
static int acpi_irq_get_penalty(int irq)
{
struct irq_penalty_info *irq_info;
if (irq < ACPI_MAX_ISA_IRQ)
return acpi_irq_isa_penalty[irq];
list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
if (irq_info->irq == irq)
return irq_info->penalty;
}
return 0;
}
static int acpi_irq_set_penalty(int irq, int new_penalty)
{
struct irq_penalty_info *irq_info;
/* see if this is a ISA IRQ */
if (irq < ACPI_MAX_ISA_IRQ) {
acpi_irq_isa_penalty[irq] = new_penalty;
return 0;
}
/* next, try to locate from the dynamic list */
list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
if (irq_info->irq == irq) {
irq_info->penalty = new_penalty;
return 0;
}
}
/* nope, let's allocate a slot for this IRQ */
irq_info = kzalloc(sizeof(*irq_info), GFP_KERNEL);
if (!irq_info)
return -ENOMEM;
irq_info->irq = irq;
irq_info->penalty = new_penalty;
list_add_tail(&irq_info->node, &acpi_irq_penalty_list);
return 0;
}
static void acpi_irq_add_penalty(int irq, int penalty)
{
int curpen = acpi_irq_get_penalty(irq);
acpi_irq_set_penalty(irq, curpen + penalty);
}
int __init acpi_irq_penalty_init(void) int __init acpi_irq_penalty_init(void)
{ {
struct acpi_pci_link *link; struct acpi_pci_link *link;
...@@ -487,15 +546,16 @@ int __init acpi_irq_penalty_init(void) ...@@ -487,15 +546,16 @@ int __init acpi_irq_penalty_init(void)
link->irq.possible_count; link->irq.possible_count;
for (i = 0; i < link->irq.possible_count; i++) { for (i = 0; i < link->irq.possible_count; i++) {
if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) {
acpi_irq_penalty[link->irq. int irqpos = link->irq.possible[i];
possible[i]] +=
penalty; acpi_irq_add_penalty(irqpos, penalty);
}
} }
} else if (link->irq.active) { } else if (link->irq.active) {
acpi_irq_penalty[link->irq.active] += acpi_irq_add_penalty(link->irq.active,
PIRQ_PENALTY_PCI_POSSIBLE; PIRQ_PENALTY_PCI_POSSIBLE);
} }
} }
...@@ -547,12 +607,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) ...@@ -547,12 +607,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
* the use of IRQs 9, 10, 11, and >15. * the use of IRQs 9, 10, 11, and >15.
*/ */
for (i = (link->irq.possible_count - 1); i >= 0; i--) { for (i = (link->irq.possible_count - 1); i >= 0; i--) {
if (acpi_irq_penalty[irq] > if (acpi_irq_get_penalty(irq) >
acpi_irq_penalty[link->irq.possible[i]]) acpi_irq_get_penalty(link->irq.possible[i]))
irq = link->irq.possible[i]; irq = link->irq.possible[i];
} }
} }
if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) { if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) {
printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. " printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. "
"Try pci=noacpi or acpi=off\n", "Try pci=noacpi or acpi=off\n",
acpi_device_name(link->device), acpi_device_name(link->device),
...@@ -568,7 +628,8 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) ...@@ -568,7 +628,8 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
acpi_device_bid(link->device)); acpi_device_bid(link->device));
return -ENODEV; return -ENODEV;
} else { } else {
acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; acpi_irq_add_penalty(link->irq.active, PIRQ_PENALTY_PCI_USING);
printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n", printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
acpi_device_name(link->device), acpi_device_name(link->device),
acpi_device_bid(link->device), link->irq.active); acpi_device_bid(link->device), link->irq.active);
...@@ -778,7 +839,7 @@ static void acpi_pci_link_remove(struct acpi_device *device) ...@@ -778,7 +839,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
} }
/* /*
* modify acpi_irq_penalty[] from cmdline * modify penalty from cmdline
*/ */
static int __init acpi_irq_penalty_update(char *str, int used) static int __init acpi_irq_penalty_update(char *str, int used)
{ {
...@@ -796,13 +857,10 @@ static int __init acpi_irq_penalty_update(char *str, int used) ...@@ -796,13 +857,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
if (irq < 0) if (irq < 0)
continue; continue;
if (irq >= ARRAY_SIZE(acpi_irq_penalty))
continue;
if (used) if (used)
acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED; acpi_irq_add_penalty(irq, PIRQ_PENALTY_ISA_USED);
else else
acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE; acpi_irq_set_penalty(irq, PIRQ_PENALTY_PCI_AVAILABLE);
if (retval != 2) /* no next number */ if (retval != 2) /* no next number */
break; break;
...@@ -819,18 +877,15 @@ static int __init acpi_irq_penalty_update(char *str, int used) ...@@ -819,18 +877,15 @@ static int __init acpi_irq_penalty_update(char *str, int used)
*/ */
void acpi_penalize_isa_irq(int irq, int active) void acpi_penalize_isa_irq(int irq, int active)
{ {
if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) { if (irq >= 0)
if (active) acpi_irq_add_penalty(irq, active ?
acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED; PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
else
acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
}
} }
bool acpi_isa_irq_available(int irq) bool acpi_isa_irq_available(int irq)
{ {
return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) || return irq >= 0 &&
acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS); (acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
} }
/* /*
...@@ -840,13 +895,18 @@ bool acpi_isa_irq_available(int irq) ...@@ -840,13 +895,18 @@ bool acpi_isa_irq_available(int irq)
*/ */
void acpi_penalize_sci_irq(int irq, int trigger, int polarity) void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
{ {
if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) { int penalty;
if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
polarity != ACPI_MADT_POLARITY_ACTIVE_LOW) if (irq < 0)
acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS; return;
else
acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING; if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
} polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
penalty = PIRQ_PENALTY_ISA_ALWAYS;
else
penalty = PIRQ_PENALTY_PCI_USING;
acpi_irq_add_penalty(irq, penalty);
} }
/* /*
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/irq.h>
#ifdef CONFIG_X86 #ifdef CONFIG_X86
#define valid_IRQ(i) (((i) != 0) && ((i) != 2)) #define valid_IRQ(i) (((i) != 0) && ((i) != 2))
...@@ -336,6 +337,31 @@ unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable) ...@@ -336,6 +337,31 @@ unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable)
} }
EXPORT_SYMBOL_GPL(acpi_dev_irq_flags); EXPORT_SYMBOL_GPL(acpi_dev_irq_flags);
/**
* acpi_dev_get_irq_type - Determine irq type.
* @triggering: Triggering type as provided by ACPI.
* @polarity: Interrupt polarity as provided by ACPI.
*/
unsigned int acpi_dev_get_irq_type(int triggering, int polarity)
{
switch (polarity) {
case ACPI_ACTIVE_LOW:
return triggering == ACPI_EDGE_SENSITIVE ?
IRQ_TYPE_EDGE_FALLING :
IRQ_TYPE_LEVEL_LOW;
case ACPI_ACTIVE_HIGH:
return triggering == ACPI_EDGE_SENSITIVE ?
IRQ_TYPE_EDGE_RISING :
IRQ_TYPE_LEVEL_HIGH;
case ACPI_ACTIVE_BOTH:
if (triggering == ACPI_EDGE_SENSITIVE)
return IRQ_TYPE_EDGE_BOTH;
default:
return IRQ_TYPE_NONE;
}
}
EXPORT_SYMBOL_GPL(acpi_dev_get_irq_type);
static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi) static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi)
{ {
res->start = gsi; res->start = gsi;
......
...@@ -417,11 +417,11 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) ...@@ -417,11 +417,11 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
if ((value & 0xf000) != sel) { if ((value & 0xf000) != sel) {
value &= 0x0fff; value &= 0x0fff;
value |= sel; value |= sel;
ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD,
ACPI_SBS_MANAGER, ACPI_SBS_MANAGER,
0x01, (u8 *)&value, 2); 0x01, (u8 *)&value, 2);
if (ret) if (ret)
goto end; goto end;
} }
} }
ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ACPI_SBS_BATTERY, ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ACPI_SBS_BATTERY,
......
...@@ -417,10 +417,15 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data) ...@@ -417,10 +417,15 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data)
* ActiveLow is only specified for GpioInt resource. If * ActiveLow is only specified for GpioInt resource. If
* GpioIo is used then the only way to set the flag is * GpioIo is used then the only way to set the flag is
* to use _DSD "gpios" property. * to use _DSD "gpios" property.
* Note: we expect here:
* - ACPI_ACTIVE_LOW == GPIO_ACTIVE_LOW
* - ACPI_ACTIVE_HIGH == GPIO_ACTIVE_HIGH
*/ */
if (lookup->info.gpioint) if (lookup->info.gpioint) {
lookup->info.active_low = lookup->info.polarity = agpio->polarity;
agpio->polarity == ACPI_ACTIVE_LOW; lookup->info.triggering = agpio->triggering;
}
} }
return 1; return 1;
...@@ -447,7 +452,7 @@ static int acpi_gpio_resource_lookup(struct acpi_gpio_lookup *lookup, ...@@ -447,7 +452,7 @@ static int acpi_gpio_resource_lookup(struct acpi_gpio_lookup *lookup,
if (info) { if (info) {
*info = lookup->info; *info = lookup->info;
if (lookup->active_low) if (lookup->active_low)
info->active_low = lookup->active_low; info->polarity = lookup->active_low;
} }
return 0; return 0;
} }
...@@ -595,6 +600,7 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, ...@@ -595,6 +600,7 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
{ {
int idx, i; int idx, i;
unsigned int irq_flags;
for (i = 0, idx = 0; idx <= index; i++) { for (i = 0, idx = 0; idx <= index; i++) {
struct acpi_gpio_info info; struct acpi_gpio_info info;
...@@ -603,8 +609,23 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) ...@@ -603,8 +609,23 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
if (IS_ERR(desc)) if (IS_ERR(desc))
break; break;
if (info.gpioint && idx++ == index) if (info.gpioint && idx++ == index) {
return gpiod_to_irq(desc); int irq = gpiod_to_irq(desc);
if (irq < 0)
return irq;
irq_flags = acpi_dev_get_irq_type(info.triggering,
info.polarity);
/* Set type if specified and different than the current one */
if (irq_flags != IRQ_TYPE_NONE &&
irq_flags != irq_get_trigger_type(irq))
irq_set_irq_type(irq, irq_flags);
return irq;
}
} }
return -ENOENT; return -ENOENT;
} }
......
...@@ -1879,7 +1879,7 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, ...@@ -1879,7 +1879,7 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
return desc; return desc;
} }
if (info.active_low) if (info.polarity == GPIO_ACTIVE_LOW)
*flags |= GPIO_ACTIVE_LOW; *flags |= GPIO_ACTIVE_LOW;
return desc; return desc;
...@@ -2217,7 +2217,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, ...@@ -2217,7 +2217,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
desc = acpi_node_get_gpiod(fwnode, propname, 0, &info); desc = acpi_node_get_gpiod(fwnode, propname, 0, &info);
if (!IS_ERR(desc)) if (!IS_ERR(desc))
active_low = info.active_low; active_low = info.polarity == GPIO_ACTIVE_LOW;
} }
if (IS_ERR(desc)) if (IS_ERR(desc))
......
...@@ -26,7 +26,8 @@ struct acpi_device; ...@@ -26,7 +26,8 @@ struct acpi_device;
*/ */
struct acpi_gpio_info { struct acpi_gpio_info {
bool gpioint; bool gpioint;
bool active_low; int polarity;
int triggering;
}; };
/* gpio suffixes used for ACPI and device tree lookup */ /* gpio suffixes used for ACPI and device tree lookup */
......
...@@ -1623,6 +1623,9 @@ static acpi_status acpi_spi_add_device(acpi_handle handle, u32 level, ...@@ -1623,6 +1623,9 @@ static acpi_status acpi_spi_add_device(acpi_handle handle, u32 level,
return AE_OK; return AE_OK;
} }
if (spi->irq < 0)
spi->irq = acpi_dev_gpio_irq_get(adev, 0);
adev->power.flags.ignore_parent = true; adev->power.flags.ignore_parent = true;
strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias)); strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias));
if (spi_add_device(spi)) { if (spi_add_device(spi)) {
......
...@@ -389,6 +389,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares, ...@@ -389,6 +389,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,
bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
struct resource_win *win); struct resource_win *win);
unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable); unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
struct resource *res); struct resource *res);
......
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