From patchwork Fri May 21 00:04:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 12271609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51D7EC433B4 for ; Fri, 21 May 2021 00:04:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EA8E61244 for ; Fri, 21 May 2021 00:04:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234808AbhEUAGS (ORCPT ); Thu, 20 May 2021 20:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234821AbhEUAGR (ORCPT ); Thu, 20 May 2021 20:06:17 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646D4C061574; Thu, 20 May 2021 17:04:55 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d78so12722493pfd.10; Thu, 20 May 2021 17:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VOb8c6DZ7VIZrD+3PTSNQOJnewy5P64QbYyctDZQTrE=; b=uaQ+eWVqskRrc2U6AMLDHjLUw6NhUlTTXoatJaJB9NRMrJNDngSJQQNCsWivgHstu+ 95Yf75yp+EB1VRElEEID7eIQP28OgfDYzOLg0h9PiuzZdsbUPLl+zIZDWxz2/AcDrU7q AucY2MFxWCn7pU9TW4D5kuYARdT5NbSC+uuyXOJlDTYB+QoGPSGsiYtC5XK3N8taoB5h Auk8C/uqqc3pQ9nZIMLXbJzLxCYFkkK9oQTyJo0AytT6GB61DcuU1twu1nRrcBmT0DRa nBWxgNHOs4Wgn81jsuZxCSiSTSPaMwphnS3bwfeESFDjvL03e25xXZ7MESFCUiEgaTRE TUUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VOb8c6DZ7VIZrD+3PTSNQOJnewy5P64QbYyctDZQTrE=; b=PKlRAI4E2qgOHFtBeVtJYteSuFlT3w24V0lOn0ggd+2gK38VDfF06m9xQekSrr45Wi PJQKu5BwzEEBMQlh6WOORLp4lIhZ1cIUweLcVKM7XIPJIjFn/AqPBAlISFUYRk3pjErR 65tdSqrFItQ9zxj3+cJiZ7lQnB2KVgi1luUIKKNwwfJ164TUY5NyF4cYE7utc3e8igoa okVi/9hgnLwH+YhXOCLiH9EN+UWvZgzCeOQzIsHTNJz7fjgaGk7+n7x6k7BXH3Ryzcoj ZShhXqHQCcaqRACDhkqwLcoJnxz7fA3iibKtIWBWoMuYHzaUrPgdEQCnXyQxTDbiKcbi jRGA== X-Gm-Message-State: AOAM532As8tZnxPtqYrzpNLCZxAokQkezjJPoVyDzjsjGNUtHumFfilS WN6rnePl8FGmH71ZUyNv5H+GNOjHoGeF1Q== X-Google-Smtp-Source: ABdhPJyLrLKfrmzXg8EPLHlFdEDRs+BVVt4V/ZEYOX4Ys+pBL+p6ZwI8lCKG0H3xudaTf5aHiObkKA== X-Received: by 2002:aa7:9f8f:0:b029:2dc:76bc:edce with SMTP id z15-20020aa79f8f0000b02902dc76bcedcemr7085511pfr.29.1621555494430; Thu, 20 May 2021 17:04:54 -0700 (PDT) Received: from kelvin-System-Product-Name.lan ([117.173.227.56]) by smtp.gmail.com with ESMTPSA id t22sm2736016pfl.50.2021.05.20.17.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 17:04:53 -0700 (PDT) From: Keguang Zhang To: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Bogendoerfer , Kelvin Cheung Subject: [PATCH 1/3] MIPS: Loongson1B: Add dma_slave_map to DMA platform data Date: Fri, 21 May 2021 08:04:03 +0800 Message-Id: <20210521000405.4387-2-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210521000405.4387-1-keguang.zhang@gmail.com> References: <20210521000405.4387-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Kelvin Cheung This patch add dma_slave_map to DMA platform data, and remove unnecessary DMA filter declaration. Signed-off-by: Kelvin Cheung --- arch/mips/include/asm/mach-loongson32/dma.h | 7 ++++--- arch/mips/include/asm/mach-loongson32/nand.h | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/mips/include/asm/mach-loongson32/dma.h b/arch/mips/include/asm/mach-loongson32/dma.h index e917b3ccb2c2..1bcf1eb8fe3d 100644 --- a/arch/mips/include/asm/mach-loongson32/dma.h +++ b/arch/mips/include/asm/mach-loongson32/dma.h @@ -8,14 +8,15 @@ #ifndef __ASM_MACH_LOONGSON32_DMA_H #define __ASM_MACH_LOONGSON32_DMA_H +#include + #define LS1X_DMA_CHANNEL0 0 #define LS1X_DMA_CHANNEL1 1 #define LS1X_DMA_CHANNEL2 2 struct plat_ls1x_dma { - int nr_channels; + const struct dma_slave_map *slave_map; + int slavecnt; }; -extern struct plat_ls1x_dma ls1b_dma_pdata; - #endif /* __ASM_MACH_LOONGSON32_DMA_H */ diff --git a/arch/mips/include/asm/mach-loongson32/nand.h b/arch/mips/include/asm/mach-loongson32/nand.h index aaf5ed19d78d..d6eff2fadca2 100644 --- a/arch/mips/include/asm/mach-loongson32/nand.h +++ b/arch/mips/include/asm/mach-loongson32/nand.h @@ -19,8 +19,4 @@ struct plat_ls1x_nand { int wait_cycle; }; -extern struct plat_ls1x_nand ls1b_nand_pdata; - -bool ls1x_dma_filter_fn(struct dma_chan *chan, void *param); - #endif /* __ASM_MACH_LOONGSON32_NAND_H */ From patchwork Fri May 21 00:04:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 12271611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44409C433B4 for ; Fri, 21 May 2021 00:05:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 161DD6138C for ; Fri, 21 May 2021 00:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234883AbhEUAGZ (ORCPT ); Thu, 20 May 2021 20:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234849AbhEUAGV (ORCPT ); Thu, 20 May 2021 20:06:21 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A20BC061574; Thu, 20 May 2021 17:04:59 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id v12so10012090plo.10; Thu, 20 May 2021 17:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v7TpLTV4vsoKBG/fnm3hLhrh2W548ux1D/aVpANdFpI=; b=VSMD7tvcClM7J6cKEVOkwIGTqAYrGVuQIY9FFniKguEN1z50nLg66po6lose8+fu6o DA7InAEuNj/1pQ5fFVqzSz5F8R777azAXHNGONbArjQeJEJaifrPrziAG7hxbxNHCjV3 yXIBe+8cY5TZ7hWMlyhx6XCeaBzs+Ie6tkBdbCPnZBEEhbzJCxZKBfSRT8yb71LRvkji 9NdeTYcY9eqpHn9UpDdwcpSz5wM9lFnwfqS8MSvLFwqcUmKUw0iFF9sQVpnXCIk79lm/ xaRkpy9/enYBac1ngY6D1OqpHlArNQa5MonyrVfzyfPXYCxp2JJ1BU8rCXxp516vNOzg beiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v7TpLTV4vsoKBG/fnm3hLhrh2W548ux1D/aVpANdFpI=; b=p3R04BCWzp6HW+B9gVx8qxSXPpnfetVEgAlxOlfAmo8ZGuCt2Hx5XfH3Y7FJdQVYjK chNpE42v+C3d+mUWnUcf3/FdNNyWB/JTfNO9TFuauJg1Cbejv8F4Q0dBI8zfKyPFvzHD 4Q7UnyJ8r7BipxYfCHfF9pfNv1drD3XaJQgB4oN7HdGctCWrdqoCUpS1kqIJDghMjxEX vefHhfTFy832gwh+G/sLmEoR1uT8NoA16esu6DnlRRMbc0z3mVMESpRmAAxJ/9WH+KyL FT62+q2AxMupzAdW1ml+INJX0yRnIGV94Q4rn01Km3DqRZrbZvcQxPGoYOC/hVPs6Rck IGYA== X-Gm-Message-State: AOAM531A6Hx1oPVr9OTTdL/817HCbjzH1jJhPLo8lIcjlXhys9Fp3Syh AlTjQjaIKd+PNUAnRU9QwWhXMPH1p5ARig== X-Google-Smtp-Source: ABdhPJyF9EiFy+ptQeujBjFfQDYOBewrafLc42wM7cIG4TeZRY2vcCNUoODbZ+2RnJPL3VevwTa7Rg== X-Received: by 2002:a17:902:dac9:b029:f2:bda7:a4b8 with SMTP id q9-20020a170902dac9b02900f2bda7a4b8mr8639734plx.15.1621555498350; Thu, 20 May 2021 17:04:58 -0700 (PDT) Received: from kelvin-System-Product-Name.lan ([117.173.227.56]) by smtp.gmail.com with ESMTPSA id t22sm2736016pfl.50.2021.05.20.17.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 17:04:57 -0700 (PDT) From: Keguang Zhang To: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Bogendoerfer , Kelvin Cheung Subject: [PATCH 2/3] MIPS: Loongson1B: Add Loongson1 dmaengine device Date: Fri, 21 May 2021 08:04:04 +0800 Message-Id: <20210521000405.4387-3-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210521000405.4387-1-keguang.zhang@gmail.com> References: <20210521000405.4387-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Kelvin Cheung This patch adds DMA Engine device its platform data for Loongson1B. Signed-off-by: Kelvin Cheung --- .../include/asm/mach-loongson32/platform.h | 2 ++ arch/mips/loongson32/common/platform.c | 36 +++++++++++++++++++ arch/mips/loongson32/ls1b/board.c | 15 +++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/mach-loongson32/platform.h b/arch/mips/include/asm/mach-loongson32/platform.h index eb83e2741887..d4d2a9baacdb 100644 --- a/arch/mips/include/asm/mach-loongson32/platform.h +++ b/arch/mips/include/asm/mach-loongson32/platform.h @@ -13,6 +13,7 @@ extern struct platform_device ls1x_uart_pdev; extern struct platform_device ls1x_cpufreq_pdev; +extern struct platform_device ls1x_dma_pdev; extern struct platform_device ls1x_eth0_pdev; extern struct platform_device ls1x_eth1_pdev; extern struct platform_device ls1x_ehci_pdev; @@ -22,6 +23,7 @@ extern struct platform_device ls1x_rtc_pdev; extern struct platform_device ls1x_wdt_pdev; void __init ls1x_clk_init(void); +void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata); void __init ls1x_rtc_set_extclk(struct platform_device *pdev); void __init ls1x_serial_set_uartclk(struct platform_device *pdev); diff --git a/arch/mips/loongson32/common/platform.c b/arch/mips/loongson32/common/platform.c index 794c96c2a4cd..2092a7ff32e0 100644 --- a/arch/mips/loongson32/common/platform.c +++ b/arch/mips/loongson32/common/platform.c @@ -77,6 +77,42 @@ struct platform_device ls1x_cpufreq_pdev = { }, }; +/* DMA */ +static struct resource ls1x_dma_resources[] = { + [0] = { + .start = LS1X_DMAC_BASE, + .end = LS1X_DMAC_BASE + SZ_4 - 1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = LS1X_DMA0_IRQ, + .end = LS1X_DMA0_IRQ, + .flags = IORESOURCE_IRQ, + }, + [2] = { + .start = LS1X_DMA1_IRQ, + .end = LS1X_DMA1_IRQ, + .flags = IORESOURCE_IRQ, + }, + [3] = { + .start = LS1X_DMA2_IRQ, + .end = LS1X_DMA2_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +struct platform_device ls1x_dma_pdev = { + .name = "ls1x-dma", + .id = -1, + .num_resources = ARRAY_SIZE(ls1x_dma_resources), + .resource = ls1x_dma_resources, +}; + +void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata) +{ + ls1x_dma_pdev.dev.platform_data = pdata; +} + /* Synopsys Ethernet GMAC */ static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { .phy_mask = 0, diff --git a/arch/mips/loongson32/ls1b/board.c b/arch/mips/loongson32/ls1b/board.c index 727e06718dab..2be4d8544444 100644 --- a/arch/mips/loongson32/ls1b/board.c +++ b/arch/mips/loongson32/ls1b/board.c @@ -12,6 +12,17 @@ #include #include +static const struct dma_slave_map ls1x_dma_slave_map[] = { + { "ls1x-nand", "dmachan0", (void *)LS1X_DMA_CHANNEL0 }, + { "ls1x-ac97", "dmachan1", (void *)LS1X_DMA_CHANNEL1 }, + { "ls1x-ac97", "dmachan2", (void *)LS1X_DMA_CHANNEL2 }, +}; + +struct plat_ls1x_dma ls1x_dma_pdata = { + .slave_map = ls1x_dma_slave_map, + .slavecnt = ARRAY_SIZE(ls1x_dma_slave_map), +}; + static const struct gpio_led ls1x_gpio_leds[] __initconst = { { .name = "LED9", @@ -36,6 +47,7 @@ static const struct gpio_led_platform_data ls1x_led_pdata __initconst = { static struct platform_device *ls1b_platform_devices[] __initdata = { &ls1x_uart_pdev, &ls1x_cpufreq_pdev, + &ls1x_dma_pdev, &ls1x_eth0_pdev, &ls1x_eth1_pdev, &ls1x_ehci_pdev, @@ -48,11 +60,12 @@ static struct platform_device *ls1b_platform_devices[] __initdata = { static int __init ls1b_platform_init(void) { ls1x_serial_set_uartclk(&ls1x_uart_pdev); + ls1x_dma_set_platdata(&ls1x_dma_pdata); gpio_led_register_device(-1, &ls1x_led_pdata); return platform_add_devices(ls1b_platform_devices, - ARRAY_SIZE(ls1b_platform_devices)); + ARRAY_SIZE(ls1b_platform_devices)); } arch_initcall(ls1b_platform_init); From patchwork Fri May 21 00:04:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 12271613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 571B3C433B4 for ; Fri, 21 May 2021 00:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33EE5613AC for ; Fri, 21 May 2021 00:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234927AbhEUAGa (ORCPT ); Thu, 20 May 2021 20:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234852AbhEUAG0 (ORCPT ); Thu, 20 May 2021 20:06:26 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3BEC061574; Thu, 20 May 2021 17:05:03 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id v12so10012156plo.10; Thu, 20 May 2021 17:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2DQOrp/2nBQQBAnbdNXHFx/Lg5dT9OWRcZXgoZ6JVwA=; b=M1g4QPrvuUpA6oe5QcQc9LE9VQvKlE5cblnk3B5EUw5qE917I5k1+J9mJ9GNmfo9SE 75oFZzpPNNVUbBWoBBpBvfExicC3MhxzxGbO1MGg4VbcaVdIL/AXgYB5WQat3ao0BazI XljUG19F6f8QpVZvB0M31Fd4q66WMKGub4j3iH5hTUXn2GPDDovETtdyJpcmNiUJ/iaz AaAhysVXPw5qDuhCMEg6fzfKCHX/FAvtzFahOtAMbwx5ynsX3DhYQAHItYy7PynKPtkS 9ZSKshW9asjeZzGhsL3B4q6Gg80ocpvXLqZkPtPpJu+5ausYbVddqMNcnCc6S47fAatR NVyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2DQOrp/2nBQQBAnbdNXHFx/Lg5dT9OWRcZXgoZ6JVwA=; b=rN0yYPmXotlKcrs8/UcieHrABLQf+ykVFo1NPKYk3WnmA6QEN24zF5lTOlLGbATc5O nKzqNfCYYbCeWlTQ/Nn3CLOA+bOYgyBRysM4nFZSx7CkpSRElzfFHOlYDm73/ZlCT5Mm /SRB5xmDnNrBR75nqQDZqNmmFyG56oJb7GaBQEzbkM4m8YItFlAkStsV7bPtcMtP695+ P81Wt2Bb9+WkC/OJnDbWK1gQa+byg2qRRHEXmfYcivxeCWRZbr/7XaRQAUzjXwK6ULlG 1pscYxvBihgZFhjkJKjeLZ+CaDvrEhIwaGoL3A0Mqa93kxArItqb+me8GfjlpqAVc4RG Nzzw== X-Gm-Message-State: AOAM5324qg3WrH3oZWk2Eiz/Fc6+eImnScFy1Xk9ztc0TXWEpXKYltYa YUuGzU623EFLPu05X6Jr1V/8aPgEIOQO3A== X-Google-Smtp-Source: ABdhPJyj5oovAUjQ+7HRZhKMz3f96P13YumlJRw+FUoH693DLPZBxupjJVAqpsWEIOUtjC7dtACL0Q== X-Received: by 2002:a17:902:dccc:b029:f1:c207:b10b with SMTP id t12-20020a170902dcccb02900f1c207b10bmr8861300pll.41.1621555502255; Thu, 20 May 2021 17:05:02 -0700 (PDT) Received: from kelvin-System-Product-Name.lan ([117.173.227.56]) by smtp.gmail.com with ESMTPSA id t22sm2736016pfl.50.2021.05.20.17.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 17:05:01 -0700 (PDT) From: Keguang Zhang To: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Bogendoerfer , Kelvin Cheung Subject: [PATCH 3/3] MIPS: Loongson1B: Add Loongson1 NAND device Date: Fri, 21 May 2021 08:04:05 +0800 Message-Id: <20210521000405.4387-4-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210521000405.4387-1-keguang.zhang@gmail.com> References: <20210521000405.4387-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Kelvin Cheung This patch adds NAND device and its platform data for Loongson1B. Signed-off-by: Kelvin Cheung --- .../include/asm/mach-loongson32/platform.h | 2 ++ arch/mips/loongson32/common/platform.c | 27 +++++++++++++++++++ arch/mips/loongson32/ls1b/board.c | 22 +++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/arch/mips/include/asm/mach-loongson32/platform.h b/arch/mips/include/asm/mach-loongson32/platform.h index d4d2a9baacdb..daf02b5c83a7 100644 --- a/arch/mips/include/asm/mach-loongson32/platform.h +++ b/arch/mips/include/asm/mach-loongson32/platform.h @@ -19,11 +19,13 @@ extern struct platform_device ls1x_eth1_pdev; extern struct platform_device ls1x_ehci_pdev; extern struct platform_device ls1x_gpio0_pdev; extern struct platform_device ls1x_gpio1_pdev; +extern struct platform_device ls1x_nand_pdev; extern struct platform_device ls1x_rtc_pdev; extern struct platform_device ls1x_wdt_pdev; void __init ls1x_clk_init(void); void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata); +void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata); void __init ls1x_rtc_set_extclk(struct platform_device *pdev); void __init ls1x_serial_set_uartclk(struct platform_device *pdev); diff --git a/arch/mips/loongson32/common/platform.c b/arch/mips/loongson32/common/platform.c index 2092a7ff32e0..d47a84ecf193 100644 --- a/arch/mips/loongson32/common/platform.c +++ b/arch/mips/loongson32/common/platform.c @@ -287,6 +287,33 @@ struct platform_device ls1x_gpio1_pdev = { .resource = ls1x_gpio1_resources, }; +/* NAND Flash */ +static struct resource ls1x_nand_resources[] = { + [0] = { + .start = LS1X_NAND_BASE, + .end = LS1X_NAND_BASE + SZ_32 - 1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .name = "dmachan0", + .start = LS1X_DMA_CHANNEL0, + .end = LS1X_DMA_CHANNEL0, + .flags = IORESOURCE_DMA, + }, +}; + +struct platform_device ls1x_nand_pdev = { + .name = "ls1x-nand", + .id = -1, + .num_resources = ARRAY_SIZE(ls1x_nand_resources), + .resource = ls1x_nand_resources, +}; + +void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata) +{ + ls1x_nand_pdev.dev.platform_data = pdata; +} + /* USB EHCI */ static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32); diff --git a/arch/mips/loongson32/ls1b/board.c b/arch/mips/loongson32/ls1b/board.c index 2be4d8544444..dd5a0ce9e4fb 100644 --- a/arch/mips/loongson32/ls1b/board.c +++ b/arch/mips/loongson32/ls1b/board.c @@ -23,6 +23,26 @@ struct plat_ls1x_dma ls1x_dma_pdata = { .slavecnt = ARRAY_SIZE(ls1x_dma_slave_map), }; +static struct mtd_partition ls1x_nand_parts[] = { + { + .name = "kernel", + .offset = 0, + .size = SZ_16M, + }, + { + .name = "rootfs", + .offset = MTDPART_OFS_APPEND, + .size = MTDPART_SIZ_FULL, + }, +}; + +struct plat_ls1x_nand ls1x_nand_pdata = { + .parts = ls1x_nand_parts, + .nr_parts = ARRAY_SIZE(ls1x_nand_parts), + .hold_cycle = 0x2, + .wait_cycle = 0xc, +}; + static const struct gpio_led ls1x_gpio_leds[] __initconst = { { .name = "LED9", @@ -53,6 +73,7 @@ static struct platform_device *ls1b_platform_devices[] __initdata = { &ls1x_ehci_pdev, &ls1x_gpio0_pdev, &ls1x_gpio1_pdev, + &ls1x_nand_pdev, &ls1x_rtc_pdev, &ls1x_wdt_pdev, }; @@ -61,6 +82,7 @@ static int __init ls1b_platform_init(void) { ls1x_serial_set_uartclk(&ls1x_uart_pdev); ls1x_dma_set_platdata(&ls1x_dma_pdata); + ls1x_nand_set_platdata(&ls1x_nand_pdata); gpio_led_register_device(-1, &ls1x_led_pdata);