Received: by 10.223.164.202 with SMTP id h10csp1193247wrb; Tue, 7 Nov 2017 23:51:17 -0800 (PST) X-Google-Smtp-Source: ABhQp+SNY4UTW5ERcECbZgGp1/E6hOBbOgFXUNUzlq/je6VbSXzo268hu1ok+nnH9+vsVYj2+jqL X-Received: by 10.99.178.77 with SMTP id t13mr1496314pgo.219.1510127477091; Tue, 07 Nov 2017 23:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510127477; cv=none; d=google.com; s=arc-20160816; b=X9ucYIOPbmQ+2oEwJH7/973MJEp5z26O0QQZHfaMjvKkvAuVBzeTjX4Mq3kb+Cb3fC /LLHnGf7WWEYrqAzp1zC+Vpz81rqj7Kbhry3VRpT8uGOczfyNwPRM1MhnPjVhswetsnr MCrrsNmZxfGKGPtEk8TF/0JseehS2F9s+KiZP5Gma8usA63dEgG0jMqU7glATA83y9lt D4iJAq2iMky35lfexAZencaqXW2VXxtkk+SLfrROblN0o/Uxe5iDPVNeewl6nXrAlHtR PRofKhT9egPj5LMpzi10h4lgnZKqNz1U4hxG3vLV1z5s7DTqC7u8VSJofuKyJhw+sR1z 118A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=AYDMA+Ccki/GgCYeDOf9TCWza8OYBoatZLbp04chwOE=; b=PGL6yqv0JcWGsI5EPcb6mz4i5iM4o7x+T5gDyz1m7nzdrbNwpoilb3BN7CiCkXu9tn Ezt05uZk2QCMHk84cPAACowRsv3V/8ozNIfTOheu4Qp1pRi3vOkQgzffDGV3B8Td2Q0j eOimtrayVIwrrmagN/8MUF7nUd8MnMRDlMmVl8IpZtdph22+xvMA6f29dZqOt8uvo09F 3WFkbVioo359pIsOn33+VAi0oFmjqhbhO6z5u+RFTzgbyMZ7PIuuTqeIY4mh9RLx+MRF bxh2uAakFpdEF+85hqCNn3QuDV94crqAYVKSLObM9WgGNRlRqXz7GI4/r3hPXOdupWq0 KFfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=emzJhxt0; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d90si3427764pfl.151.2017.11.07.23.51.04; Tue, 07 Nov 2017 23:51:17 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=emzJhxt0; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755049AbdKHG0n (ORCPT + 91 others); Wed, 8 Nov 2017 01:26:43 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45127 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754063AbdKHGU3 (ORCPT ); Wed, 8 Nov 2017 01:20:29 -0500 Received: by mail-pf0-f195.google.com with SMTP id d28so1120403pfe.2; Tue, 07 Nov 2017 22:20:27 -0800 (PST) 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 :in-reply-to:references; bh=AYDMA+Ccki/GgCYeDOf9TCWza8OYBoatZLbp04chwOE=; b=emzJhxt0c4HqomdHZXrkIB7lO1CPuS5DXRssahS7NbwrJN42KKd0AWLwavCUd6BETD IvoXSPNaoa75XhABRCGZmMX+cnuX79WIhp1+rogBS4C3CNlmHCBlY7vNJBAT0l9o7RiM C1kd6RymSgie4HZTCrpgTAWY4DzcxgfQKQVZW1XwujduNlr1Uwl2ry3LVCLNB7XPSzCg XeEf+zjug6oDF+FbNsuhGdUSIuSJ30hoJaE9v/iPOuzvotadu1auEgC3IYepEfgWisv9 k7WBk5deqTIZ6ibc8KFPwlhBTabX2kDOFI1eqT1lzYXBAtDv0ASw0lRJ9bB6gbCxNPQ+ VcWw== 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:in-reply-to:references; bh=AYDMA+Ccki/GgCYeDOf9TCWza8OYBoatZLbp04chwOE=; b=IMvVzN6TnOP31K8ezJuiGpAQb4XaGQOMIviqKfAaDryaRkEWrfqC3VagdVel6O4cZf N/10CCI/ABO9p78+weiLNkTyEo/BRysuj2GAQAKN0KQoDU8ura/3oKxgkXf9yravCiOn rMQeP5eJNyhM6pSEmSIAiZwlJTV/BktaqzeK7MJw/hMcfg8wbfGOU4zYOJKhfpJ/B6GR w3djt9+UjiI9MdrlkmiSRQ2cTHzvZTcejF9JJE45qdRPEKrWJ8aoXuiEcJrwQUDvOsaa nCg2eXJtHLUJLp7dOS6DGeY2gvu8S8mysMGggd9FR8s6HCatAqQGI3AqqjRDFVhJ2sbe g3WA== X-Gm-Message-State: AJaThX41y8Vuj682Rds4bL4SOclxlqKr0kV/ka2TXQz20fCDMuk4CAKp D8lljDGkmKH0Xam6+Gsftck= X-Received: by 10.98.224.11 with SMTP id f11mr1385040pfh.43.1510122026823; Tue, 07 Nov 2017 22:20:26 -0800 (PST) Received: from app09.andestech.com ([118.163.51.199]) by smtp.gmail.com with ESMTPSA id a4sm6581339pfj.72.2017.11.07.22.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 22:20:26 -0800 (PST) From: Greentime Hu To: greentime@andestech.com, linux-kernel@vger.kernel.org, arnd@arndb.de, linux-arch@vger.kernel.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, netdev@vger.kernel.org Cc: green.hu@gmail.com, Vincent Chen Subject: [PATCH 12/31] nds32: Device specific operations Date: Wed, 8 Nov 2017 13:55:00 +0800 Message-Id: <4e9acf2ec55fb26ddb290ca2d955eeea628e0a77.1510118606.git.green.hu@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greentime Hu Signed-off-by: Vincent Chen Signed-off-by: Greentime Hu --- arch/nds32/include/asm/io.h | 33 +++++++++++++++++++++ arch/nds32/mm/ioremap.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 arch/nds32/include/asm/io.h create mode 100644 arch/nds32/mm/ioremap.c diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h new file mode 100644 index 0000000..98b3ae9 --- /dev/null +++ b/arch/nds32/include/asm/io.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Andes Technology Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __ASM_NDS32_IO_H +#define __ASM_NDS32_IO_H + +#ifdef __KERNEL__ + +#include +extern void __iomem *__ioremap(unsigned long, size_t, unsigned long, + unsigned long); +extern void __iounmap(void __iomem * addr); + +#define ioremap(cookie,size) __ioremap(cookie,size,0,1) +#define ioremap_nocache(cookie,size) __ioremap(cookie,size,0,1) +#define iounmap(cookie) __iounmap(cookie) +#include + +#endif /* __KERNEL__ */ +#endif /* __ASM_NDS32_IO_H */ diff --git a/arch/nds32/mm/ioremap.c b/arch/nds32/mm/ioremap.c new file mode 100644 index 0000000..532e6cf --- /dev/null +++ b/arch/nds32/mm/ioremap.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2005-2017 Andes Technology Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +void __iomem *__ioremap(unsigned long phys_addr, size_t size, + unsigned long flags, unsigned long align) +{ + struct vm_struct *area; + unsigned long addr, offset, last_addr; + pgprot_t prot; + + /* Don't allow wraparound or zero size */ + last_addr = phys_addr + size - 1; + if (!size || last_addr < phys_addr) + return NULL; + + /* + * Mappings have to be page-aligned + */ + offset = phys_addr & ~PAGE_MASK; + phys_addr &= PAGE_MASK; + size = PAGE_ALIGN(last_addr + 1) - phys_addr; + + /* + * Ok, go for it.. + */ + area = get_vm_area(size, VM_IOREMAP); + if (!area) + return NULL; + + area->phys_addr = phys_addr; + addr = (unsigned long)area->addr; + prot = __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | + _PAGE_G | _PAGE_C_DEV); + if (ioremap_page_range(addr, addr + size, phys_addr, prot)) { + vunmap((void *)addr); + return NULL; + } + return (__force void __iomem *)(offset + (char *)addr); + +} + +EXPORT_SYMBOL(__ioremap); + +void __iounmap(void __iomem * addr) +{ + vunmap((void *)(PAGE_MASK & (unsigned long)addr)); +} + +EXPORT_SYMBOL(__iounmap); -- 1.7.9.5 From 1584958808108274638@xxx Fri Nov 24 14:41:47 +0000 2017 X-GM-THRID: 1584142038298704251 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread