linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Ishizaki Kou <kou.ishizaki@toshiba.co.jp>
Cc: linuxppc-dev@ozlabs.org, paulus@samba.org
Subject: Re: [PATCH 4/11] Celleb: support iommu
Date: Mon, 29 Jan 2007 08:32:04 +1100	[thread overview]
Message-ID: <1170019925.26655.31.camel@localhost.localdomain> (raw)
In-Reply-To: <200701261152.l0QBqAb5012882@toshiba.co.jp>

On Fri, 2007-01-26 at 20:52 +0900, Ishizaki Kou wrote:
> This patch creates Celleb platform dependent file to support iommu.
> 
> Signed-off-by: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> ---
> 
> Index: linux-powerpc-git/arch/powerpc/platforms/celleb/iommu.c
> diff -u /dev/null linux-powerpc-git/arch/powerpc/platforms/celleb/iommu.c:1.19
> --- /dev/null	Fri Jan 26 19:47:00 2007
> +++ linux-powerpc-git/arch/powerpc/platforms/celleb/iommu.c	Fri Jan 26 17:45:04 2007
> @@ -0,0 +1,104 @@
> +/*
> + * Support for IOMMU on Celleb platform.
> + *
> + * (C) Copyright 2006-2007 TOSHIBA CORPORATION
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * 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, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/pci.h>
> +
> +#include <asm/of_platform.h>
> +
> +#include "beat_wrapper.h"
> +
> +#define DMA_FLAGS 0xf800000000000000UL	/* r/w permitted, coherency required,
> +					   strongest order */
> +
> +static int __init find_dma_window(u64 *io_space_id, u64 *ioid,
> +				  u64 *base, u64 *size, u64 *io_page_size)
> +{
> +	struct device_node *dn;
> +	const unsigned long *dma_window;
> +
> +	for_each_node_by_type(dn, "ioif") {
> +		dma_window = get_property(dn, "toshiba,dma-window", NULL);
> +		if (dma_window) {
> +			*io_space_id = (dma_window[0] >> 32) & 0xffffffffUL;
> +			*ioid = dma_window[0] & 0x7ffUL;
> +			*base = dma_window[1];
> +			*size = dma_window[2];
> +			*io_page_size = 1 << dma_window[3];
> +			of_node_put(dn);
> +			return 1;
> +		}
> +	}
> +	return 0;
> +}
> +
> +static void __init celleb_init_direct_mapping(void)
> +{
> +	u64 lpar_addr, io_addr;
> +	u64 io_space_id, ioid, dma_base, dma_size, io_page_size;
> +
> +	if (!find_dma_window(&io_space_id, &ioid, &dma_base, &dma_size,
> +			     &io_page_size)) {
> +		pr_info("No dma window found !\n");
> +		return;
> +	}
> +
> +	for (lpar_addr = 0; lpar_addr < dma_size; lpar_addr += io_page_size) {
> +		io_addr = lpar_addr + dma_base;
> +		(void)beat_put_iopte(io_space_id, io_addr, lpar_addr,
> +				     ioid, DMA_FLAGS);
> +	}
> +
> +	dma_direct_offset = dma_base;
> +}
> +
> +static int celleb_of_bus_notify(struct notifier_block *nb,
> +				unsigned long action, void *data)
> +{
> +	struct device *dev = data;
> +
> +	/* We are only intereted in device addition */
> +	if (action != BUS_NOTIFY_ADD_DEVICE)
> +		return 0;
> +
> +	dev->archdata.dma_ops = pci_dma_ops;
> +
> +	return 0;
> +}
> +
> +static struct notifier_block celleb_of_bus_notifier = {
> +	.notifier_call = celleb_of_bus_notify
> +};
> +
> +static int __init celleb_init_iommu(void)
> +{
> +	if (!machine_is(celleb))
> +		return -ENODEV;
> +
> +	celleb_init_direct_mapping();
> +	pci_dma_ops = &dma_direct_ops;
> +	bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier);
> +
> +	return 0;
> +}
> +
> +arch_initcall(celleb_init_iommu);
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

  reply	other threads:[~2007-01-28 21:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-26 11:52 [PATCH 4/11] Celleb: support iommu Ishizaki Kou
2007-01-28 21:32 ` Benjamin Herrenschmidt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-02-02  7:39 Ishizaki Kou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1170019925.26655.31.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=kou.ishizaki@toshiba.co.jp \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).