Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1746633ybg; Sat, 19 Oct 2019 01:36:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVd+Ertapf8f2xAN4D/IKM0zLchsMS8I1fkveRW7uxgqxXsOl0ezOTTQ/RzGjg3prJCFTq X-Received: by 2002:a17:906:300a:: with SMTP id 10mr12725735ejz.104.1571474215560; Sat, 19 Oct 2019 01:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571474215; cv=none; d=google.com; s=arc-20160816; b=fakmTbcyy3/sHtXqfuFcQ8CIaLEQM2i8pHQ0c4ugKWkVORHobq0y+BsJf9XPEWYuqL iGkMoXwPXn7NrkGB2Ip57UOs1vQ4uozQsWYf9QxdUl28taaifxkoJObUuYo4xPLP/Few qu7+MwXxVFO4BF9zSsEFSJVguoQ46QRg0XM0JgHM/JICiaRE2EKqOSZ9q44SoZCl4BSE EDL64PhwpKrY9qNRewKMQ1lTTDLYBtB1otp1TGG9AMOgOwC9/Tf5nWzL1C3xiQUbscVE ao4dA0NKlNEvGaCqdJeaXI6kccjbPMY/jRdT4ku/d6y0dKYr/p+3oUeU+wTkutNLB/Hn Uz5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=eID8tVaOlY7Aw+kQrSMjoluUZfs5pixBuaXh/6OsTZw=; b=CIa4GtjpvP6VwkcbwL45aKiuwnXGFwvSx7QaEffVQ0C/PofjlmEx4jcXmJG6IYuDMk xsZY+BSSjJgvMATW51Rpdt4YrPengSxkuHb1TLyhip4P9UdEed4zqh+CK2ifwWh7QqfN xuvfs/0TLZCXGE+ZIqxUSx6i6VubYCiTEZLc9k44Ff5FQTieVXP03p3zvpvN40fNm3Qm MLQLKv8GXNwviOgvb86HuG/TmmZtocxOwSZgzz37sS7RyaU1EhW/DYEI4rNucYVgneT7 pd0hrcafHf0J9V9VA3eZfI/8SmqS+B3CSX1Ad7xYJA1rhB9zrsYnIE2mzFJTOhkqceZK /nrQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si5144845edq.250.2019.10.19.01.36.32; Sat, 19 Oct 2019 01:36:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408993AbfJRPo3 (ORCPT + 99 others); Fri, 18 Oct 2019 11:44:29 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:43807 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408933AbfJRPml (ORCPT ); Fri, 18 Oct 2019 11:42:41 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1McY4R-1hklXG0AYf-00cyGG; Fri, 18 Oct 2019 17:42:31 +0200 From: Arnd Bergmann To: Daniel Mack , Haojian Zhuang , Robert Jarzmik Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij , Arnd Bergmann , Dominik Brodowski Subject: [PATCH 33/46] ARM: pxa: pcmcia: move smemc configuration back to arch Date: Fri, 18 Oct 2019 17:41:48 +0200 Message-Id: <20191018154201.1276638-33-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191018154052.1276506-1-arnd@arndb.de> References: <20191018154052.1276506-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:DxmH2LbQts0InxyxX242/6orRSxw7B2eJs5alq6ovf8VEIfUb1e UZLkuu4zbqGUYzh8bXbjGhPHAuE7IWtUvRkJsrYOTVyLkPFu+sN0iZ2AYJ/Ruy1xBpMoODO MBAK6lOCRMRdG9ct64YHJgEe2ug8h0m0Q+xUS7VsuovBC7AW5Y+9RMMeZghwwjY0/Q8oqSj /MgezRfvSGUpKTEVFylnA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:WrnuPQtaRkI=:aNhI30tV/l0Fs9GdIHOfm4 aPUOAjUVBVlceAwKIXu+nBeC8AIogNOMtkD4dqJrK7mcOXxk3t2B4recC/1NoWOBNPNb6fU7F iHMMov6kqXJRMwgk+s5sTJHamgOpl9Slb8AVU8RYDhinl2aJhMnOZB3aj1lEAFyrIUo/kVEql 3ZxoTy0miU0x7DIzze0QdufvwMjRu8s0eM4lzOUYamFB916hPXszevUVUJi512EoYRtiKBc7z y7hq1jDkjNIefOSgqhnYtrdZfPLFC2qibIB1X91n79UhW5ihdqIP0kPZ9qBdCDyJSn7b/a5Qy hDjels/uHN9r9hyyfCNgGQHf8+pILYGL/uPTzjqQgHPg4RHJHGVe3CG3OfMdqMLqk2UNfgRCs 3WN7p6O2rmSTRRbmBsxv9075NFdAJ1RjaUZZzCfTW8GeZCB7RBQ1WLeBC882w30bLnw1D/Z1x Xt2vt60+QICZZQPcu+InljDyGfql8R5CSr3yPunmfi6qMGuFsYDTuzEpX/Q33VyOArXpRyqZE YDCwHsak6Mc0u0rrxrkrzqFSWFGgnnmT9NhJcHcxaZqI/R8WcTwwhnN2FvyA3vXLRO/8DUJsq h4OPpRqdYQ1J1JzM/CvlQBAOnIJCBXDDYaz/QjBZ8JlZ9BRMYQjOQ69Id4Ur4qyuD+JyyPnlM KyxNE/Yqa2rvR0E9kG+Nzs/prbwLE7EtJmUve3hzZbb372ZlL9mTgTbLNiDQr6AzkSh2mIxC/ cfbaVecWYcueyFCyx51RICqmkShMQ+PcXca+l3NPgqAuzPn3Lhu9I8LrzmeqEDqlxEAG11q4L AUpM+3gq+PV6jTOYiFZiPfikTyM2nFfmMuQqZn4kDmh5Us4pjCOzVMg9BzlsjdTPBZ9/crWaz dy7PM9mSbfkIJZpPSM8Q== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rather than poking at the smemc registers directly from the pcmcia/pxa2xx_base driver, move those bits into machine file to have a cleaner interface. Cc: Dominik Brodowski Signed-off-by: Arnd Bergmann --- arch/arm/mach-pxa/generic.c | 29 ++++++++++++++++++++++ drivers/pcmcia/pxa2xx_base.c | 46 ++++++++++++----------------------- include/linux/soc/pxa/smemc.h | 10 ++++++++ 3 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 include/linux/soc/pxa/smemc.h diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c index f9083c4f0aea..fe1d55d328e5 100644 --- a/arch/arm/mach-pxa/generic.c +++ b/arch/arm/mach-pxa/generic.c @@ -70,6 +70,35 @@ unsigned int get_clk_frequency_khz(int info) } EXPORT_SYMBOL(get_clk_frequency_khz); +void pxa_smemc_set_pcmcia_timing(int sock, u32 mcmem, u32 mcatt, u32 mcio) +{ + __raw_writel(mcmem, MCMEM(sock)); + __raw_writel(mcatt, MCATT(sock)); + __raw_writel(mcio, MCIO(sock)); +} +EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_timing); + +void pxa_smemc_set_pcmcia_socket(int nr) +{ + switch (nr) { + case 0: + __raw_writel(0, MECR); + break; + case 1: + /* + * We have at least one socket, so set MECR:CIT + * (Card Is There) + */ + __raw_writel(MECR_CIT, MECR); + break; + case 2: + /* Set CIT and MECR:NOS (Number Of Sockets) */ + __raw_writel(MECR_CIT | MECR_NOS, MECR); + break; + } +} +EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_socket); + /* * Intel PXA2xx internal register mapping. * diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 7cd1375d6087..13880137f175 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c @@ -24,11 +24,10 @@ #include #include #include +#include -#include #include #include -#include #include #include @@ -113,7 +112,7 @@ static inline u_int pxa2xx_pcmcia_cmd_time(u_int mem_clk_10khz, return (300000 * (pcmcia_mcxx_asst + 1) / mem_clk_10khz); } -static int pxa2xx_pcmcia_set_mcmem( int sock, int speed, int clock ) +static uint32_t pxa2xx_pcmcia_mcmem(int sock, int speed, int clock) { uint32_t val; @@ -124,12 +123,10 @@ static int pxa2xx_pcmcia_set_mcmem( int sock, int speed, int clock ) | ((pxa2xx_mcxx_hold(speed, clock) & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); - __raw_writel(val, MCMEM(sock)); - - return 0; + return val; } -static int pxa2xx_pcmcia_set_mcio( int sock, int speed, int clock ) +static int pxa2xx_pcmcia_mcio(int sock, int speed, int clock) { uint32_t val; @@ -140,12 +137,11 @@ static int pxa2xx_pcmcia_set_mcio( int sock, int speed, int clock ) | ((pxa2xx_mcxx_hold(speed, clock) & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); - __raw_writel(val, MCIO(sock)); - return 0; + return val; } -static int pxa2xx_pcmcia_set_mcatt( int sock, int speed, int clock ) +static int pxa2xx_pcmcia_mcatt(int sock, int speed, int clock) { uint32_t val; @@ -156,31 +152,26 @@ static int pxa2xx_pcmcia_set_mcatt( int sock, int speed, int clock ) | ((pxa2xx_mcxx_hold(speed, clock) & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); - __raw_writel(val, MCATT(sock)); - return 0; + return val; } -static int pxa2xx_pcmcia_set_mcxx(struct soc_pcmcia_socket *skt, unsigned int clk) +static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) { + unsigned long clk = clk_get_rate(skt->clk) / 1000; struct soc_pcmcia_timing timing; int sock = skt->nr; soc_common_pcmcia_get_timing(skt, &timing); - pxa2xx_pcmcia_set_mcmem(sock, timing.mem, clk); - pxa2xx_pcmcia_set_mcatt(sock, timing.attr, clk); - pxa2xx_pcmcia_set_mcio(sock, timing.io, clk); + pxa_smemc_set_pcmcia_timing(sock, + pxa2xx_pcmcia_mcmem(sock, timing.mem, clk), + pxa2xx_pcmcia_mcatt(sock, timing.attr, clk), + pxa2xx_pcmcia_mcio(sock, timing.io, clk)); return 0; } -static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) -{ - unsigned long clk = clk_get_rate(skt->clk); - return pxa2xx_pcmcia_set_mcxx(skt, clk / 10000); -} - #ifdef CONFIG_CPU_FREQ static int @@ -215,18 +206,13 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt, void pxa2xx_configure_sockets(struct device *dev, struct pcmcia_low_level *ops) { - /* - * We have at least one socket, so set MECR:CIT - * (Card Is There) - */ - uint32_t mecr = MECR_CIT; + int nr = 1; - /* Set MECR:NOS (Number Of Sockets) */ if ((ops->first + ops->nr) > 1 || machine_is_viper() || machine_is_arcom_zeus()) - mecr |= MECR_NOS; + nr = 2; - __raw_writel(mecr, MECR); + pxa_smemc_set_pcmcia_socket(nr); } EXPORT_SYMBOL(pxa2xx_configure_sockets); diff --git a/include/linux/soc/pxa/smemc.h b/include/linux/soc/pxa/smemc.h new file mode 100644 index 000000000000..cbf1a2d8af29 --- /dev/null +++ b/include/linux/soc/pxa/smemc.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __PXA_REGS_H +#define __PXA_REGS_H + +#include + +void pxa_smemc_set_pcmcia_timing(int sock, u32 mcmem, u32 mcatt, u32 mcio); +void pxa_smemc_set_pcmcia_socket(int nr); + +#endif -- 2.20.0