From patchwork Thu Feb 14 15:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10813113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC8391399 for ; Thu, 14 Feb 2019 15:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F152ED07 for ; Thu, 14 Feb 2019 15:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC0B92ED1B; Thu, 14 Feb 2019 15:58:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3868B2ED07 for ; Thu, 14 Feb 2019 15:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sqtOUY4TXN8NewWx0eK0ij++Os38Ua4SvY/vT93eM40=; b=a4IEKZS8sj8ppy xcp1YmNmpRF5k1b1qXZb2Sn+eAXMiJnIH3CiVNUh5MFwi/Wp/qWOBXzModFhdyhmNvIj9XCkOu/c6 CZJlFsOnvrkLlFQFsWi/3HrrG9a5vTZPDE8G6re1oMgrqbt3u8OIogKKlH95B+C0qXhq3bsSMMJo9 OhPCHSyDQfoc2sw18cAcP3HYpdZEHXlbWEm8MHCpyxEj//fxYFBAJKIay75M7pJx52CdMW5k/ASyQ 45z6faXJrJdc8LG+r85vBQgW0H0V3+CllcZbF7Sv+WuEDFbgEXep3dRJqkX6he65jxBLtfU9mqILM mpKlK3gddBWX6LMGgyyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1guJPL-0001rg-3c; Thu, 14 Feb 2019 15:58:39 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1guJPG-0001r5-Tg for linux-arm-kernel@lists.infradead.org; Thu, 14 Feb 2019 15:58:37 +0000 X-IronPort-AV: E=Sophos;i="5.58,369,1544511600"; d="scan'208";a="26282615" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 14 Feb 2019 08:58:30 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.38) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 14 Feb 2019 08:54:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/jCBcqsRwjIM07nNLPQYFr06+xQGEPsUG7q4ai/eXgg=; b=TrQk11sgoOpcV/GXccrqc59+j3RDUx6LbBwu1n3kBLIC+it8fft0uUheH9ODgKmO5ixd1D3vwe3CjN6ifRZvNdMdhvYu09kmoSrEdOZo78zEvF5qM3mErjckO9hoXrOWt4mvP74fPOnpKD+TUiGhUmG4itlhskBe2taww8t7NtQ= Received: from MWHPR11MB1920.namprd11.prod.outlook.com (10.175.54.19) by MWHPR11MB2031.namprd11.prod.outlook.com (10.169.236.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.17; Thu, 14 Feb 2019 15:54:57 +0000 Received: from MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::d917:8496:9d53:1f55]) by MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::d917:8496:9d53:1f55%9]) with mapi id 15.20.1622.016; Thu, 14 Feb 2019 15:54:57 +0000 From: To: , , , , , , , Subject: [PATCH 6/8] ARM: at91: pm: add ULP1 support for SAM9X60 Thread-Topic: [PATCH 6/8] ARM: at91: pm: add ULP1 support for SAM9X60 Thread-Index: AQHUxH2i/1SZGNr49EScTe5mg81JaQ== Date: Thu, 14 Feb 2019 15:54:57 +0000 Message-ID: <1550159642-26878-7-git-send-email-claudiu.beznea@microchip.com> References: <1550159642-26878-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1550159642-26878-1-git-send-email-claudiu.beznea@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0901CA0098.eurprd09.prod.outlook.com (2603:10a6:800:7e::24) To MWHPR11MB1920.namprd11.prod.outlook.com (2603:10b6:300:110::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [213.233.85.122] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d35de275-e0bb-4c03-9143-08d69294c452 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020); SRVR:MWHPR11MB2031; x-ms-traffictypediagnostic: MWHPR11MB2031: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; MWHPR11MB2031; 23:oqxcaEAIHh2yjkRpqmh0XzsKsT9uAQ/dtYCh48V?= =?iso-8859-1?q?hIQ6Nk6uM2cIYRs?= =?iso-8859-1?q?Q2VFQIYHfG0Qz6r/pUjxO4IJDLhahgyVbqR18GaPJGwFvMSbZmyNc3+vo1zY?= =?iso-8859-1?q?Bs5BXzpSCsRKbHyPrlrs5bqQCsFrzcw3/53ppXV4cPPyC2fd+bzdI1iW7RQ+?= =?iso-8859-1?q?EEuh+Pl8qZprf6yyHQ321rzrKcObx1NppneQWbNLyrQz9BET8fw1TMr0hDGg?= =?iso-8859-1?q?lrp8XFlvngLPuC/JYzj6JZQ2kraB8y/i21D748CnU8BgoGtRmKDD5DZDso+0?= =?iso-8859-1?q?l1AHplQxSHOaEcGUFBIXfOCxSHLcg6zih3x0X5FPIf/nyTsWWd9BeDXa0gWc?= =?iso-8859-1?q?lLVmuhcnTEa04OW4SH5sKXSMG0mJL7W/3jVeScoI/fTPosDKi8uug2jqunoT?= =?iso-8859-1?q?oUSnzMe9xM0iUyW8Pcy44xLjbfOANm7Fdgjdu3Fi0oQhcaSR/7rox0cOz2Ut?= =?iso-8859-1?q?+N8rjALhOJNERMJjarJbpA5jxkoaH8lylYVj39dbTJbv+52TV2RjmlgyZArH?= =?iso-8859-1?q?BBlQ88sI7bdMTI1ItJQcrOONxXsXoaijiosLo1n5qKb8a8DWwdHb7jXlAUzY?= =?iso-8859-1?q?GK1FcePeOUtDtkPTBfASKJS++tmRJ+IMykh5IarGsTOmLDL3Q35hMxL4ljHp?= =?iso-8859-1?q?FD6l6IkB6NlYZeSbHuUgFcNADOe8H8g3wiJt3P3pRJrlIC64/r+IisNyU9qI?= =?iso-8859-1?q?tfhjwujQqiUK0RFvjaiy7B8a0k9nq5LDZwPXLksJcAMfLnV/2QgV/KiMzv7f?= =?iso-8859-1?q?i/NlenNnW9U1FRdTnFLyWtgSzFQiOKeXAoiWbyrBsCJnuJ0QU8PzB0rGKxq/?= =?iso-8859-1?q?TcR83jTMQ+Tm8fZRGSRwR70RaHZ2vlUKRmN6EaIVSudwDQjcJ+EL1A7KAskD?= =?iso-8859-1?q?pwlESIa9euCKmBwIgyfXInRI90CQWm/24BT4mhfaf3sZD3F2xC38ZKZSexF8?= =?iso-8859-1?q?GsE6VxY7vd306NcuFEv3ZPZ6Txcry6rMXdfINkf9Tc/cBKOPHeBMfSKsShce?= =?iso-8859-1?q?bQy95U21IeQdaNZhAGAocEAgNb46+dTw81NJQZ0644qhF2r0obwRzilslEZd?= =?iso-8859-1?q?SHhV3AIzYnaq8vPcrl09xjAudHRFCtVJGc8i18lMh0SzjZBkyLRpejfNbDk0?= =?iso-8859-1?q?Cd3Yb0wArjg88WdmNoak0ygWfSf99b5NIatVouEi0tSrJUadGyw/fvzAeZto?= =?iso-8859-1?q?4MvSr3T5lLiVgeyjN93vxEVnZhYXOoWb2PA84nLOmhThpNUCMSCXtUBfWjZO?= =?iso-8859-1?q?L4jmlDnuL7hq0Fgy1G1XrZXMY+2TTgg98jv5/CNLYQJBaNM/0qzAneonRWLj?= =?iso-8859-1?q?CHkyyNe2c=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09480768F8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(39860400002)(136003)(376002)(366004)(189003)(199004)(97736004)(6486002)(2906002)(72206003)(14454004)(478600001)(81156014)(36756003)(2501003)(71190400001)(71200400001)(316002)(81166006)(7416002)(110136005)(54906003)(6436002)(76176011)(66066001)(50226002)(14444005)(256004)(6512007)(106356001)(8936002)(68736007)(52116002)(2201001)(26005)(186003)(446003)(53936002)(11346002)(6116002)(7736002)(3846002)(25786009)(107886003)(4326008)(305945005)(99286004)(8676002)(105586002)(486006)(86362001)(386003)(476003)(6506007)(102836004)(2616005)(357404004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR11MB2031; H:MWHPR11MB1920.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: aHV6p3dJPsztkezn3d/jvqsYXLcuoSAP4vrycL3gO3Y4eCLNGgQdUb3rajV4fzuyruBukY6HEWty1lUtoWoRIGSU8VcHpIshIl93EiKDRBKmIdB26uMh03r2rR5k3G3RPlUlj82nyg+p//+kXFSacBj4ORz3dbQatKN4j1Nm2MyhsvKTL6Z6EK8Wr1rxwKLSjbnGNKvM9V/ep5Cf3yXkjt51mumJeqVV4SwxItvCEIAYZmLF7Ehs3k9+G3b2YJWyiTnEZ2w0QHGzp5pypbo3iLT5m+skwme12oozfWXBnfDnCMTQijJDCi6dNWdK4K+ptI6SHjrPDv5FMNgr62EJHuYiWv2CAkIgZUw2IRG4q79y6/AgfPw03wftsFFIEKE29eJuaXbdU6W0OuoCS8Jzd9xuv1W4UBMO1u9LTjPaM8Y= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: d35de275-e0bb-4c03-9143-08d69294c452 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2019 15:54:52.4100 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB2031 X-OriginatorOrg: microchip.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190214_075836_031283_1F455CC0 X-CRM114-Status: GOOD ( 14.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Claudiu.Beznea@microchip.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Claudiu Beznea Add ULP1 support for SAM9X60. In pm_suspend.S enable RC oscillator in PMC if it is not enabled. At resume the state before suspend is restored. Signed-off-by: Claudiu Beznea Acked-by: Stephen Boyd --- arch/arm/mach-at91/pm.c | 24 ++++++++++++++++++++++++ arch/arm/mach-at91/pm_suspend.S | 41 ++++++++++++++++++++++++++++++++++++++++- include/linux/clk/at91_pmc.h | 1 + 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 27264caa4ec6..5571658b3c46 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -100,6 +100,8 @@ static const struct wakeup_source_info ws_info[] = { { .pmc_fsmr_bit = AT91_PMC_RTCAL, .shdwc_mr_bit = BIT(17) }, { .pmc_fsmr_bit = AT91_PMC_USBAL }, { .pmc_fsmr_bit = AT91_PMC_SDMMC_CD }, + { .pmc_fsmr_bit = AT91_PMC_RTTAL }, + { .pmc_fsmr_bit = AT91_PMC_RXLP_MCE }, }; static const struct of_device_id sama5d2_ws_ids[] = { @@ -114,6 +116,17 @@ static const struct of_device_id sama5d2_ws_ids[] = { { /* sentinel */ } }; +static const struct of_device_id sam9x60_ws_ids[] = { + { .compatible = "atmel,at91sam9x5-rtc", .data = &ws_info[1] }, + { .compatible = "atmel,at91rm9200-ohci", .data = &ws_info[2] }, + { .compatible = "usb-ohci", .data = &ws_info[2] }, + { .compatible = "atmel,at91sam9g45-ehci", .data = &ws_info[2] }, + { .compatible = "usb-ehci", .data = &ws_info[2] }, + { .compatible = "atmel,at91sam9260-rtt", .data = &ws_info[4] }, + { .compatible = "cdns,sam9x60-macb", .data = &ws_info[5] }, + { /* sentinel */ } +}; + static int at91_pm_config_ws(unsigned int pm_mode, bool set) { const struct wakeup_source_info *wsi; @@ -192,6 +205,13 @@ static int at91_sama5d2_config_pmc_ws(void __iomem *pmc, u32 mode, u32 polarity) return 0; } +static int at91_sam9x60_config_pmc_ws(void __iomem *pmc, u32 mode, u32 polarity) +{ + writel(mode, pmc + AT91_PMC_FSMR); + + return 0; +} + /* * Called after processes are frozen, but before we shutdown devices. */ @@ -789,8 +809,12 @@ void __init sam9x60_pm_init(void) if (!IS_ENABLED(CONFIG_SOC_AT91SAM9)) return; + at91_pm_modes_init(); at91_dt_ramc(); at91_pm_init(at91sam9x60_idle); + + soc_pm.ws_ids = sam9x60_ws_ids; + soc_pm.config_pmc_ws = at91_sam9x60_config_pmc_ws; } void __init at91sam9_pm_init(void) diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S index bfe1c4d06901..8b18cad1dcf5 100644 --- a/arch/arm/mach-at91/pm_suspend.S +++ b/arch/arm/mach-at91/pm_suspend.S @@ -197,8 +197,26 @@ ENDPROC(at91_backup_mode) .macro at91_pm_ulp1_mode ldr pmc, .pmc_base - /* Switch the main clock source to 12-MHz RC oscillator */ + /* Save RC oscillator state and check if it is enabled. */ + ldr tmp1, [pmc, #AT91_PMC_SR] + str tmp1, .saved_osc_status + tst tmp1, #AT91_PMC_MOSCRCS + bne 2f + + /* Enable RC oscillator */ ldr tmp1, [pmc, #AT91_CKGR_MOR] + orr tmp1, tmp1, #AT91_PMC_MOSCRCEN + bic tmp1, tmp1, #AT91_PMC_KEY_MASK + orr tmp1, tmp1, #AT91_PMC_KEY + str tmp1, [pmc, #AT91_CKGR_MOR] + + /* Wait main RC stabilization */ +1: ldr tmp1, [pmc, #AT91_PMC_SR] + tst tmp1, #AT91_PMC_MOSCRCS + beq 1b + + /* Switch the main clock source to 12-MHz RC oscillator */ +2: ldr tmp1, [pmc, #AT91_CKGR_MOR] bic tmp1, tmp1, #AT91_PMC_MOSCSEL bic tmp1, tmp1, #AT91_PMC_KEY_MASK orr tmp1, tmp1, #AT91_PMC_KEY @@ -262,6 +280,25 @@ ENDPROC(at91_backup_mode) str tmp1, [pmc, #AT91_PMC_MCKR] wait_mckrdy + + /* Restore RC oscillator state */ + ldr tmp1, .saved_osc_status + tst tmp1, #AT91_PMC_MOSCRCS + bne 3f + + /* Disable RC oscillator */ + ldr tmp1, [pmc, #AT91_CKGR_MOR] + bic tmp1, tmp1, #AT91_PMC_MOSCRCEN + bic tmp1, tmp1, #AT91_PMC_KEY_MASK + orr tmp1, tmp1, #AT91_PMC_KEY + str tmp1, [pmc, #AT91_CKGR_MOR] + + /* Wait RC oscillator disable done */ +4: ldr tmp1, [pmc, #AT91_PMC_SR] + tst tmp1, #AT91_PMC_MOSCRCS + bne 4b + +3: .endm ENTRY(at91_ulp_mode) @@ -475,6 +512,8 @@ ENDPROC(at91_sramc_self_refresh) .word 0 .saved_sam9_mdr1: .word 0 +.saved_osc_status: + .word 0 ENTRY(at91_pm_suspend_in_sram_sz) .word .-at91_pm_suspend_in_sram diff --git a/include/linux/clk/at91_pmc.h b/include/linux/clk/at91_pmc.h index 931ab05f771d..bd3a65c0bad3 100644 --- a/include/linux/clk/at91_pmc.h +++ b/include/linux/clk/at91_pmc.h @@ -159,6 +159,7 @@ #define AT91_PMC_FSMR 0x70 /* Fast Startup Mode Register */ #define AT91_PMC_FSTT(n) BIT(n) +#define AT91_PMC_RTTAL BIT(16) #define AT91_PMC_RTCAL BIT(17) /* RTC Alarm Enable */ #define AT91_PMC_USBAL BIT(18) /* USB Resume Enable */ #define AT91_PMC_SDMMC_CD BIT(19) /* SDMMC Card Detect Enable */