Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1621263imm; Fri, 6 Jul 2018 03:33:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfyVOWhyI/mIBWiePgNKSa1M0yWO85TXtWd/snuT8sG2nf87KuBaDEdepkcYaNigblf3iq6 X-Received: by 2002:a62:104e:: with SMTP id y75-v6mr10077135pfi.109.1530873236591; Fri, 06 Jul 2018 03:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530873236; cv=none; d=google.com; s=arc-20160816; b=r0cR25widVii4bemkBaPoDF/ff+JUSgtzuLpvfvDFHUsuso2xXjDR3tJcsw1R4BZeA CYx1bhBdom2cCvEttL12Nq+yWo5pNlFmKPpNDSE+Qlv1BoK2R4VKL44I0plmP10cGyIl YfsEbhjxlWiNnMokv6Jj1dqx4Mj85039ioWyL/h4G8nfW5PLB2UCqutjUOoPix84alQ8 HSozrrOc/f3kAHAldKAV/l+1kX6fJ0GxyQvoS4HkkrB0fQnOKcKlychpjU4DM/umxE9e UIZ3nIyqdChERwtnuatwZtp0BDdwYX0oZ6auZbaOpdnc3/SrzBDqMsDzT3bYiqBDf1yR xbng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=eGKK89frvgkfwiw1cvFCUfT7zPYuVFc7UqTUMYvaAj8=; b=qJdIlghUFWPQ3swWq0QIKRtnA6gy7EJ274KcON3C0VahjosHCN4/6nV0eQmkYS4LVo /Lj6GzcVGVBhN1ZFHj7OOC3kGXj2qzpX7HtlQG6Mz2OoBhXasy5HX2hccr+dv/KohoR+ J31S1E65NXJs18L1DKx1X6X6Bq6CeBGZJCTnRV70BMCK2/3af/x3Fz7V+JpYr3xRpBQY 1ONcLLYHt6nyeyIrPzZMPgiX5yDYtMxmjvufX9y/V0hLtvbf8bPRBPbOPA1lvRN8PeJU /8LwA35sVmiMefdiqM+uh6KUwYC26r03rw5waa7051ZhZOy+AY2rrioa2qV6q4sff6P7 RoVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=GixpAFpQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v17-v6si6400869pgk.135.2018.07.06.03.33.41; Fri, 06 Jul 2018 03:33:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=GixpAFpQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753804AbeGFKc6 (ORCPT + 99 others); Fri, 6 Jul 2018 06:32:58 -0400 Received: from smtprelay4.synopsys.com ([198.182.47.9]:60562 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753535AbeGFKc4 (ORCPT ); Fri, 6 Jul 2018 06:32:56 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id E869824E2376; Fri, 6 Jul 2018 03:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1530873176; bh=tZA8AM0LhOJ+w/ACIpq1SEWzD5JXisGGDHtHvAPYyFQ=; h=From:To:Cc:Subject:Date:From; b=GixpAFpQ2Rdc7YaL/oohezE1EJaTABZaB5mmlTg7V7QBimDTpfnBgTNdUTh+jfE+t 0kKzqfmi7Lpdv6sqXLbXtRntH2FOL0TzwwXAz7k9dsSFmri7Wr7cqtVbUw+l8XQkJP EDbc4uFzPUKqVLWGPnDNCgrc702mIyLIPcAOFJxjlTMZ0pj3C8/sxx1Oo7tOG/IdqQ 8gbo8/hpUQNvG6EeuyEh4KlWd6LEc6Y8ZjYpUijGfJhOzHkdepB+VFKQ7E07GY/7L0 4Bu23+WlvhaqeuDyfjZYiXh5uziExkDlmsbaOTJnLzeb9SYm/ZpIE+QCt2/VLuza3y W8svA5/I4MIXg== Received: from pt02.synopsys.com (pt02.internal.synopsys.com [10.107.23.240]) by mailhost.synopsys.com (Postfix) with ESMTP id 6B57C5706; Fri, 6 Jul 2018 03:32:55 -0700 (PDT) Received: from UbuntuMate-64Bits.internal.synopsys.com (gustavo-e7480.internal.synopsys.com [10.107.25.102]) by pt02.synopsys.com (Postfix) with ESMTP id BC2C13EB12; Fri, 6 Jul 2018 11:32:54 +0100 (WEST) From: Gustavo Pimentel To: Vineet.Gupta1@synopsys.com, eugeniy.paltsev@synopsys.com, robh@kernel.org, sboyd@codeaurora.org, Alexey.Brodkin@synopsys.com, joao.pinto@synopsys.com Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, Gustavo Pimentel Subject: [PATCH v2] ARC: Configure APB GPIO controller on ARC HSDK platform Date: Fri, 6 Jul 2018 11:32:37 +0100 Message-Id: <5f3c59cdf0f4eb8bf22ca27031187fd866ffbecc.1530872741.git.gustavo.pimentel@synopsys.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of HSDK we have intermediate INTC in for of DW APB GPIO controller which is used as a de-bounce logic for interrupt wires that come from outside the board. We cannot use existing "irq-dw-apb-ictl" driver here because all input lines are routed to corresponding output lines but not muxed into one line (this is configured in RTL and we cannot change this in software). But even if we add such a feature to "irq-dw-apb-ictl" driver that won't benefit us as higher-level INTC (in case of HSDK it is IDU) anyways has per-input control so adding fully-controller intermediate INTC will only bring some overhead on interrupt processing but no other benefits. Thus we just do one-time configuration of DW APB GPIO controller and forget about it. Based on implementation available on arch/arc/plat-axs10x/axs10x.c file. Signed-off-by: Gustavo Pimentel --- arch/arc/plat-hsdk/platform.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/arch/arc/plat-hsdk/platform.c b/arch/arc/plat-hsdk/platform.c index 2958aed..2588b84 100644 --- a/arch/arc/plat-hsdk/platform.c +++ b/arch/arc/plat-hsdk/platform.c @@ -42,6 +42,66 @@ static void __init hsdk_init_per_cpu(unsigned int cpu) #define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108) #define SDIO_UHS_REG_EXT_DIV_2 (2 << 30) +#define HSDK_GPIO_INTC (ARC_PERIPHERAL_BASE + 0x3000) + +static void __init hsdk_enable_gpio_intc_wire(void) +{ + /* + * Peripherals on CPU Card are wired to cpu intc via intermediate + * DW APB GPIO blocks (mainly for debouncing) + * + * --------------------- + * | snps,archs-intc | + * --------------------- + * | + * ---------------------- + * | snps,archs-idu-intc | + * ---------------------- + * | | | | | + * | [eth] [USB] [... other peripherals] + * | + * ------------------- + * | snps,dw-apb-intc | + * ------------------- + * | | | | + * [Bt] [HAPS] [... other peripherals] + * + * Current implementation of "irq-dw-apb-ictl" driver doesn't work well + * with stacked INTCs. In particular problem happens if its master INTC + * not yet instantiated. See discussion here - + * https://lkml.org/lkml/2015/3/4/755 + * + * So setup the first gpio block as a passive pass thru and hide it from + * DT hardware topology - connect intc directly to cpu intc + * The GPIO "wire" needs to be init nevertheless (here) + * + * One side adv is that peripheral interrupt handling avoids one nested + * intc ISR hop + * + * According to HSDK User's Manual [1], "Table 2 Interrupt Mapping" + * we have the following GPIO input lines used as sources of interrupt: + * - GPIO[0] - Bluetooth interrupt of RS9113 module + * - GPIO[2] - HAPS interrupt (on HapsTrak 3 connector) + * - GPIO[3] - Audio codec (MAX9880A) interrupt + * - GPIO[8-23] - Available on Arduino and PMOD_x headers + * For now there's no use of Arduino and PMOD_x headers in Linux + * use-case so we only enable lines 0, 2 and 3. + * + * [1] https://github.com/foss-for-synopsys-dwc-arc-processors/ARC-Development-Systems-Forum/wiki/docs/ARC_HSDK_User_Guide.pdf + */ +#define GPIO_INTEN (HSDK_GPIO_INTC + 0x30) +#define GPIO_INTMASK (HSDK_GPIO_INTC + 0x34) +#define GPIO_INTTYPE_LEVEL (HSDK_GPIO_INTC + 0x38) +#define GPIO_INT_POLARITY (HSDK_GPIO_INTC + 0x3c) +#define GPIO_INT_CONNECTED_MASK 0x0d + + iowrite32(0xffffffff, (void __iomem *) GPIO_INTMASK); + iowrite32(~GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTMASK); + iowrite32(0x00000000, (void __iomem *) GPIO_INTTYPE_LEVEL); + iowrite32(0xffffffff, (void __iomem *) GPIO_INT_POLARITY); + iowrite32(GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTEN); +} + static void __init hsdk_init_early(void) { /* @@ -62,6 +122,8 @@ static void __init hsdk_init_early(void) * minimum possible div-by-2. */ iowrite32(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT); + + hsdk_enable_gpio_intc_wire(); } static const char *hsdk_compat[] __initconst = { -- 2.7.4