From patchwork Mon Aug 6 10:46:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10507 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9CAFA2402A for ; Mon, 6 Aug 2012 10:47:04 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6BEBBA18D28 for ; Mon, 6 Aug 2012 10:47:04 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id g10so558437ghb.11 for ; Mon, 06 Aug 2012 03:47:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=8GOV0kxmXnJdRhkq9ohCRguSH+aMh1G5NM7s1I8P6CM=; b=YKkh1I3RRJqopKfFh00arWBneCSZFrc7xIsS9MjjDVoJDAJLujRdUlwF5PMCWU5ImE 1zLcoLCwfu27D7/omMEZNfvQKcPIWB5hDw7Oq4t8mhXpmL4mzx8E7mms4K/tweMx4Fky BBu+We+fm67gnbIcesbI3T8o/I7WSq6966qIun8j+S7Hqm4tjkK/izJqUDkaDVn/kp4m 58c100isR7IE8jYg7nI8/OgpE8exXu/stEcJlM6dilOctBrmMIJ8M+aMr/k5RCsfkT4i AlG7BNIUtSwBIDQLizRjUyCqYiwTU+CJfGePqogRcePiZWlwCOuN9THtnY5dW3twVAwF ak6w== Received: by 10.50.47.161 with SMTP id e1mr4870010ign.11.1344250023904; Mon, 06 Aug 2012 03:47:03 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.87.40 with SMTP id u8csp433403igz; Mon, 6 Aug 2012 03:47:03 -0700 (PDT) Received: by 10.216.242.196 with SMTP id i46mr5138527wer.140.1344250022707; Mon, 06 Aug 2012 03:47:02 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id f2si14698889wiz.13.2012.08.06.03.47.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 03:47:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f178.google.com with SMTP id hr14so1182556wib.13 for ; Mon, 06 Aug 2012 03:47:02 -0700 (PDT) Received: by 10.180.100.133 with SMTP id ey5mr17405857wib.4.1344250022256; Mon, 06 Aug 2012 03:47:02 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id t7sm22043908wix.6.2012.08.06.03.47.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 03:47:01 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, dmitry.torokhov@gmail.com, sameo@linux.intel.com, Lee Jones Subject: [PATCH 2/6] mfd: Provide the PRCMU with its own IRQ domain Date: Mon, 6 Aug 2012 11:46:38 +0100 Message-Id: <1344250002-6011-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1344250002-6011-1-git-send-email-lee.jones@linaro.org> References: <1344250002-6011-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQk5WedIbWsTghcxGQ8dkIFb5C7eltfFEIgzUTPiyvWEdPh6HPbDMP7QOK48KMhs/aUB5neY The PRCMU has its own USB, Thermal, GPIO, Modem, HSI and RTC drivers, amongst other things. This patch allows those subordinate devices to use it as an interrupt controller as and when they are DT enabled. Signed-off-by: Lee Jones --- drivers/mfd/db8500-prcmu.c | 54 +++++++++++++++++++++++++++++--------- include/linux/mfd/db8500-prcmu.h | 2 ++ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 7040a00..937ce3a 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c @@ -270,6 +270,8 @@ static struct { struct prcmu_fw_version version; } fw_info; +struct irq_domain *db8500_irq_domain; + /* * This vector maps irq numbers to the bits in the bit field used in * communication with the PRCMU firmware. @@ -2583,7 +2585,7 @@ static void prcmu_irq_mask(struct irq_data *d) spin_lock_irqsave(&mb0_transfer.dbb_irqs_lock, flags); - mb0_transfer.req.dbb_irqs &= ~prcmu_irq_bit[d->irq - IRQ_PRCMU_BASE]; + mb0_transfer.req.dbb_irqs &= ~prcmu_irq_bit[d->hwirq]; spin_unlock_irqrestore(&mb0_transfer.dbb_irqs_lock, flags); @@ -2597,7 +2599,7 @@ static void prcmu_irq_unmask(struct irq_data *d) spin_lock_irqsave(&mb0_transfer.dbb_irqs_lock, flags); - mb0_transfer.req.dbb_irqs |= prcmu_irq_bit[d->irq - IRQ_PRCMU_BASE]; + mb0_transfer.req.dbb_irqs |= prcmu_irq_bit[d->hwirq]; spin_unlock_irqrestore(&mb0_transfer.dbb_irqs_lock, flags); @@ -2637,9 +2639,43 @@ static char *fw_project_name(u8 project) } } +int db8500_irq_get_virq(int irq) +{ + return irq_create_mapping(db8500_irq_domain, irq); +} +EXPORT_SYMBOL_GPL(db8500_irq_get_virq); + +static int db8500_irq_map(struct irq_domain *d, unsigned int virq, + irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(virq, &prcmu_irq_chip, + handle_simple_irq); + set_irq_flags(virq, IRQF_VALID); + + return 0; +} + +static struct irq_domain_ops db8500_irq_ops = { + .map = db8500_irq_map, + .xlate = irq_domain_xlate_twocell, +}; + +static int db8500_irq_init(struct device_node *np) +{ + db8500_irq_domain = irq_domain_add_legacy( + np, NUM_PRCMU_WAKEUPS, IRQ_PRCMU_BASE, + 0, &db8500_irq_ops, NULL); + + if (!db8500_irq_domain) { + pr_err("Failed to create irqdomain\n"); + return -ENOSYS; + } + + return 0; +} + void __init db8500_prcmu_early_init(void) { - unsigned int i; if (cpu_is_u8500v2()) { void *tcpm_base = ioremap_nocache(U8500_PRCMU_TCPM_BASE, SZ_4K); @@ -2683,16 +2719,6 @@ void __init db8500_prcmu_early_init(void) init_completion(&mb5_transfer.work); INIT_WORK(&mb0_transfer.mask_work, prcmu_mask_work); - - /* Initalize irqs. */ - for (i = 0; i < NUM_PRCMU_WAKEUPS; i++) { - unsigned int irq; - - irq = IRQ_PRCMU_BASE + i; - irq_set_chip_and_handler(irq, &prcmu_irq_chip, - handle_simple_irq); - set_irq_flags(irq, IRQF_VALID); - } } static void __init init_prcm_registers(void) @@ -2999,6 +3025,8 @@ static int __devinit db8500_prcmu_probe(struct platform_device *pdev) goto no_irq_return; } + db8500_irq_init(np); + for (i = 0; i < ARRAY_SIZE(db8500_prcmu_devs); i++) { if (!strcmp(db8500_prcmu_devs[i].name, "ab8500-core")) { db8500_prcmu_devs[i].platform_data = ab8500_platdata; diff --git a/include/linux/mfd/db8500-prcmu.h b/include/linux/mfd/db8500-prcmu.h index b82f6ee..38494d9 100644 --- a/include/linux/mfd/db8500-prcmu.h +++ b/include/linux/mfd/db8500-prcmu.h @@ -571,6 +571,8 @@ u32 db8500_prcmu_read(unsigned int reg); void db8500_prcmu_write(unsigned int reg, u32 value); void db8500_prcmu_write_masked(unsigned int reg, u32 mask, u32 value); +int db8500_irq_get_virq(int irq); + #else /* !CONFIG_MFD_DB8500_PRCMU */ static inline void db8500_prcmu_early_init(void) {}