From patchwork Tue Sep 18 18:21:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1474191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 169383FCFC for ; Tue, 18 Sep 2012 18:28:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TE2V9-00083A-9q; Tue, 18 Sep 2012 18:26:27 +0000 Received: from mail-we0-f201.google.com ([74.125.82.201]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TE2TO-0007K9-Qv for linux-arm-kernel@lists.infradead.org; Tue, 18 Sep 2012 18:24:45 +0000 Received: by weyx56 with SMTP id x56so6071wey.0 for ; Tue, 18 Sep 2012 11:24:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=yaIo1gSxer7i3ZD7yvZ/twAT7xPgblc5jPH4vhaWNcU=; b=C23lNtrtF3eZtOi/tBa46sWN6p5/refKu2nv2kIN1m3Q2M5nK6maEdjNJdfBi18cnj nU2rg+MaiCVdhAH006E9oOKieH2M8CJPcdE+Q40gTzUx9w/ah21oSJjTEWuyBEzmo2Zc 7cw82NI2d4jKoOnurOT54OJLMY0k0/ccq6aANbQc9nj3faerbtrE0LVPTg0MZgKzkREy 4fuwf8HXBQw51BzlcJfVIl5Z2lFywXuMz9dF9fUnjBzyWcg/8IbFVkVwKLMShVtlXpAG TgypmBr09w5+8DlSdIjDfpbI/xDoeNOyVfrnbo1jcmQq40Qsgp6cKLZoGtFHWPtI+p++ TpMw== Received: by 10.180.73.173 with SMTP id m13mr180818wiv.4.1347992673974; Tue, 18 Sep 2012 11:24:33 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id i17si3016023wiw.0.2012.09.18.11.24.33 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 18 Sep 2012 11:24:33 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 6A964200057; Tue, 18 Sep 2012 11:24:33 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id BE0D0161DAA; Tue, 18 Sep 2012 11:24:32 -0700 (PDT) From: Simon Glass To: LKML , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] spi: s3c64xx: Add support for ISP SPI ports Date: Tue, 18 Sep 2012 11:21:55 -0700 Message-Id: <1347992519-6904-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1347992519-6904-1-git-send-email-sjg@chromium.org> References: <1347992519-6904-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnctNWZDaAh25L6CfJroZTBdGczRSpHMt2BmFFM+385c2qdRPezam9g+cLm4phZS6gNbl2P/H85kdimpJBFyvLlv5uuPYOJNNeUXpSIhZr+mtXieS3Rmu+71EK9MP/J6NKfK2HX+bsNNIr5fZtOE82hpDuGVvpXTPK4Sgvu1GzNXitnGk/7r6NtX4K8xIItPLpyh9L4UfqnxJmUyCtkbxTnEDphYw== X-Spam-Note: CRM114 invocation failed X-Spam-Score: -3.1 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.201 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Simon Glass , "kgene.kim" , Ben Dooks , Srinivas KANDAGATLA X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The ISP has two SPI ports which can be used for general SPI activities. Add support for these for: - clocks and clock gating - SPI FIFO size for these ports - support for 'samsung,pd' node in SPI so we can mark these ports as dependent on the ISP power domain Signed-off-by: Simon Glass --- arch/arm/mach-exynos/clock-exynos5.c | 69 ++++++++++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 2 + arch/arm/mach-exynos/include/mach/regs-clock.h | 1 + arch/arm/mach-exynos/mach-exynos5-dt.c | 4 ++ drivers/spi/spi-s3c64xx.c | 13 ++++- 5 files changed, 87 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-exynos/clock-exynos5.c b/arch/arm/mach-exynos/clock-exynos5.c index 774533c..f40eaaf 100644 --- a/arch/arm/mach-exynos/clock-exynos5.c +++ b/arch/arm/mach-exynos/clock-exynos5.c @@ -186,6 +186,11 @@ static int exynos5_clk_ip_peris_ctrl(struct clk *clk, int enable) return s5p_gatectrl(EXYNOS5_CLKGATE_IP_PERIS, clk, enable); } +static int exynos5_clksrc_mask_isp_ctrl(struct clk *clk, int enable) +{ + return s5p_gatectrl(EXYNOS5_SCLK_SRC_MASK_ISP, clk, enable); +} + static int exynos5_clk_ip_gscl_ctrl(struct clk *clk, int enable) { return s5p_gatectrl(EXYNOS5_CLKGATE_IP_GSCL, clk, enable); @@ -764,6 +769,18 @@ static struct clk exynos5_init_clocks_off[] = { .enable = exynos5_clk_ip_peric_ctrl, .ctrlbit = (1 << 18), }, { + .name = "spi", + .devname = "exynos4210-spi.3", + .parent = &exynos5_clk_aclk_66.clk, + .enable = exynos5_clk_ip_isp1_ctrl, + .ctrlbit = (1 << 12), + }, { + .name = "spi", + .devname = "exynos4210-spi.4", + .parent = &exynos5_clk_aclk_66.clk, + .enable = exynos5_clk_ip_isp1_ctrl, + .ctrlbit = (1 << 13), + }, { .name = SYSMMU_CLOCK_NAME, .devname = SYSMMU_CLOCK_DEVNAME(mfc_l, 0), .enable = &exynos5_clk_ip_mfc_ctrl, @@ -1120,6 +1137,50 @@ static struct clksrc_clk exynos5_clk_sclk_spi2 = { .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC2, .shift = 8, .size = 8 }, }; +static struct clksrc_clk exynos5_clk_mdout_spi3 = { + .clk = { + .name = "sclk_spi_mdout", + .devname = "exynos4210-spi.3", + }, + .sources = &exynos5_clkset_group, + .reg_src = { .reg = EXYNOS5_SCLK_SRC_ISP, .shift = 0, .size = 4 }, + .reg_div = { .reg = EXYNOS5_SCLK_DIV_ISP, .shift = 0, .size = 4 }, + +}; + +static struct clksrc_clk exynos5_clk_sclk_spi3 = { + .clk = { + .name = "sclk_spi", + .devname = "exynos4210-spi.3", + .parent = &exynos5_clk_mdout_spi3.clk, + .enable = exynos5_clksrc_mask_isp_ctrl, + .ctrlbit = (1 << 0), + }, + .reg_div = { .reg = EXYNOS5_SCLK_DIV_ISP, .shift = 4, .size = 8 }, +}; + +static struct clksrc_clk exynos5_clk_mdout_spi4 = { + .clk = { + .name = "sclk_spi_mdout", + .devname = "exynos4210-spi.4", + }, + .sources = &exynos5_clkset_group, + .reg_src = { .reg = EXYNOS5_SCLK_SRC_ISP, .shift = 4, .size = 4 }, + .reg_div = { .reg = EXYNOS5_SCLK_DIV_ISP, .shift = 12, .size = 4 }, + +}; + +static struct clksrc_clk exynos5_clk_sclk_spi4 = { + .clk = { + .name = "sclk_spi", + .devname = "exynos4210-spi.4", + .parent = &exynos5_clk_mdout_spi4.clk, + .enable = exynos5_clksrc_mask_isp_ctrl, + .ctrlbit = (1 << 4), + }, + .reg_div = { .reg = EXYNOS5_SCLK_DIV_ISP, .shift = 16, .size = 8 }, +}; + static struct clksrc_clk exynos5_clksrcs[] = { { .clk = { @@ -1237,9 +1298,13 @@ static struct clksrc_clk *exynos5_sysclks[] = { &exynos5_clk_sclk_spi0, &exynos5_clk_sclk_spi1, &exynos5_clk_sclk_spi2, + &exynos5_clk_sclk_spi3, + &exynos5_clk_sclk_spi4, &exynos5_clk_mdout_spi0, &exynos5_clk_mdout_spi1, &exynos5_clk_mdout_spi2, + &exynos5_clk_mdout_spi3, + &exynos5_clk_mdout_spi4, }; static struct clk *exynos5_clk_cdev[] = { @@ -1271,6 +1336,10 @@ static struct clk_lookup exynos5_clk_lookup[] = { CLKDEV_INIT("exynos4210-spi.0", "spi_busclk0", &exynos5_clk_sclk_spi0.clk), CLKDEV_INIT("exynos4210-spi.1", "spi_busclk0", &exynos5_clk_sclk_spi1.clk), CLKDEV_INIT("exynos4210-spi.2", "spi_busclk0", &exynos5_clk_sclk_spi2.clk), + CLKDEV_INIT("exynos4210-spi.3", "spi_busclk0", + &exynos5_clk_sclk_spi3.clk), + CLKDEV_INIT("exynos4210-spi.4", "spi_busclk0", + &exynos5_clk_sclk_spi4.clk), CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0), CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1), CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1), diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h index c72b675..4d46a5f 100644 --- a/arch/arm/mach-exynos/include/mach/map.h +++ b/arch/arm/mach-exynos/include/mach/map.h @@ -157,6 +157,8 @@ #define EXYNOS5_PA_SPI0 0x12D20000 #define EXYNOS5_PA_SPI1 0x12D30000 #define EXYNOS5_PA_SPI2 0x12D40000 +#define EXYNOS5_PA_SPI3 0x131A0000 +#define EXYNOS5_PA_SPI4 0x131B0000 #define EXYNOS4_PA_GPIO1 0x11400000 #define EXYNOS4_PA_GPIO2 0x11000000 diff --git a/arch/arm/mach-exynos/include/mach/regs-clock.h b/arch/arm/mach-exynos/include/mach/regs-clock.h index 8c9b38c..d03f83d 100644 --- a/arch/arm/mach-exynos/include/mach/regs-clock.h +++ b/arch/arm/mach-exynos/include/mach/regs-clock.h @@ -301,6 +301,7 @@ #define EXYNOS5_CLKSRC_MASK_FSYS EXYNOS_CLKREG(0x10340) #define EXYNOS5_CLKSRC_MASK_PERIC0 EXYNOS_CLKREG(0x10350) #define EXYNOS5_CLKSRC_MASK_PERIC1 EXYNOS_CLKREG(0x10354) +#define EXYNOS5_SCLK_SRC_MASK_ISP EXYNOS_CLKREG(0x10370) #define EXYNOS5_CLKDIV_TOP0 EXYNOS_CLKREG(0x10510) #define EXYNOS5_CLKDIV_TOP1 EXYNOS_CLKREG(0x10514) diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c index ef770bc..76c5126 100644 --- a/arch/arm/mach-exynos/mach-exynos5-dt.c +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c @@ -53,6 +53,10 @@ static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = { "exynos4210-spi.1", NULL), OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI2, "exynos4210-spi.2", NULL), + OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI3, + "exynos4210-spi.3", NULL), + OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI4, + "exynos4210-spi.4", NULL), OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA0, "dma-pl330.0", NULL), OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.1", NULL), OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_MDMA1, "dma-pl330.2", NULL), diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 3152659..95a1bfc 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -30,11 +30,12 @@ #include #include #include +#include #include #include -#define MAX_SPI_PORTS 3 +#define MAX_SPI_PORTS 5 /* Registers and bit-fields */ @@ -1345,6 +1346,14 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) goto err8; } +#ifdef CONFIG_PM + if (pdev->dev.of_node) { + if (pm_genpd_of_add_device_by_name(pdev->dev.of_node, + &pdev->dev, "samsung,pd")) + dev_err(&pdev->dev, "failed to add to genpd\n"); + } +#endif + dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d " "with %d Slaves attached\n", sdd->port_id, master->num_chipselect); @@ -1513,7 +1522,7 @@ struct s3c64xx_spi_port_config s5pv210_spi_port_config = { }; struct s3c64xx_spi_port_config exynos4_spi_port_config = { - .fifo_lvl_mask = { 0x1ff, 0x7F, 0x7F }, + .fifo_lvl_mask = { 0x1ff, 0x7F, 0x7F, 0x1ff, 0x1ff }, .rx_lvl_offset = 15, .tx_st_done = 25, .high_speed = true,