LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Recommended functions for accessing internal registers
From: Fortini Matteo @ 2009-12-01 16:44 UTC (permalink / raw)
  To: linuxppc-dev@lists.ozlabs.org

I see that throughout the kernel source, internal PPC registers are 
accessed through [in|out]_be[32|16|8]() functions. However, they are 
translated into 3 inline assembly instructions, one of which is an 
isync, which has a huge performance hit.
I tried using readl_be() which seems to be the right function according 
to the Documentation/ dir, but it is translated directly to in_be32(), 
so no luck.

Is it really necessary to use all those instructions? I know I could use 
a (volatile u32 *) variable to avoid subsequent read/writes to be 
optimized out, but it seems to be a deprecated use.

Thank you in advance,
Matteo

^ permalink raw reply

* Re: [PATCH 0/8 userland!] systemtap: Add initial support for ppc32
From: Frank Ch. Eigler @ 2009-12-01 17:54 UTC (permalink / raw)
  To: avorontsov; +Cc: linuxppc-dev, systemtap
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

Anton Vorontsov <avorontsov@ru.mvista.com> writes:

> Here are some patches that add systemtap support for ppc32 machines.
> [...]

Thanks, committed, with a little extra for ppc64 compatibility.

- FChE

^ permalink raw reply

* Re: [RFC PATCH v2 01/11] powerpc: gamecube/wii: usbgecko bootwrapper console support
From: Segher Boessenkool @ 2009-12-01 18:28 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <1259441037-15725-2-git-send-email-albert_herranz@yahoo.es>

> Add support for using the USB Gecko adapter as a bootwrapper  
> console on
> the Nintendo GameCube and Wii video game consoles.
> The USB Gecko is a 3rd party memory card interface adapter that  
> provides
> a EXI (External Interface) to USB serial converter.
>
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> ---
> v1 -> v2
> - Probe dinamically for usbgecko. Suggestion by Segher Boessenkool.
> - Adapt to updated device tree.
>
>  arch/powerpc/boot/Makefile |    2 +-
>  arch/powerpc/boot/ugecon.c |  147 +++++++++++++++++++++++++++++++++ 
> +++++++++++
>  arch/powerpc/boot/ugecon.h |   24 +++++++
>  3 files changed, 172 insertions(+), 1 deletions(-)
>  create mode 100644 arch/powerpc/boot/ugecon.c
>  create mode 100644 arch/powerpc/boot/ugecon.h
>
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 7bfc8ad..44bce21 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -66,7 +66,7 @@ src-wlib := string.S crt0.S crtsavres.S stdio.c  
> main.c \
>  		gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
>  		4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
>  		cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \
> -		fsl-soc.c mpc8xx.c pq2.c
> +		fsl-soc.c mpc8xx.c pq2.c ugecon.c
>  src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c  
> cuboot-85xx.c holly.c \
>  		cuboot-ebony.c cuboot-hotfoot.c treeboot-ebony.c prpmc2800.c \
>  		ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
> diff --git a/arch/powerpc/boot/ugecon.c b/arch/powerpc/boot/ugecon.c
> new file mode 100644
> index 0000000..50609ea
> --- /dev/null
> +++ b/arch/powerpc/boot/ugecon.c
> @@ -0,0 +1,147 @@
> +/*
> + * arch/powerpc/boot/ugecon.c
> + *
> + * USB Gecko bootwrapper console.
> + * Copyright (C) 2008-2009 The GameCube Linux Team
> + * Copyright (C) 2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#include <stddef.h>
> +#include "stdio.h"
> +#include "types.h"
> +#include "io.h"
> +#include "ops.h"
> +
> +
> +#define EXI_CLK_32MHZ           5
> +
> +#define EXI_CSR                 0x00
> +#define   EXI_CSR_CLKMASK       (0x7<<4)
> +#define     EXI_CSR_CLK_32MHZ   (EXI_CLK_32MHZ<<4)
> +#define   EXI_CSR_CSMASK        (0x7<<7)
> +#define     EXI_CSR_CS_0        (0x1<<7)  /* Chip Select 001 */
> +
> +#define EXI_CR                  0x0c
> +#define   EXI_CR_TSTART         (1<<0)
> +#define   EXI_CR_WRITE		(1<<2)
> +#define   EXI_CR_READ_WRITE     (2<<2)
> +#define   EXI_CR_TLEN(len)      (((len)-1)<<4)
> +
> +#define EXI_DATA                0x10
> +
> +
> +/* virtual address base for input/output, retrieved from device  
> tree */
> +static void *ug_io_base;
> +
> +
> +static u32 ug_io_transaction(u32 in)
> +{
> +	u32 *csr_reg = ug_io_base + EXI_CSR;
> +	u32 *data_reg = ug_io_base + EXI_DATA;
> +	u32 *cr_reg = ug_io_base + EXI_CR;
> +	u32 csr, data, cr;
> +
> +	/* select */
> +	csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
> +	out_be32(csr_reg, csr);
> +
> +	/* read/write */
> +	data = in;
> +	out_be32(data_reg, data);
> +	cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
> +	out_be32(cr_reg, cr);
> +
> +	while (in_be32(cr_reg) & EXI_CR_TSTART)
> +		barrier();
> +
> +	/* deselect */
> +	out_be32(csr_reg, 0);
> +
> +	data = in_be32(data_reg);
> +	return data;
> +}
> +
> +static int ug_is_txfifo_ready(void)
> +{
> +	return ug_io_transaction(0xc0000000) & 0x04000000;
> +}
> +
> +static void ug_raw_putc(char ch)
> +{
> +	ug_io_transaction(0xb0000000 | (ch << 20));
> +}
> +
> +static void ug_putc(char ch)
> +{
> +	int count = 16;
> +
> +	if (!ug_io_base)
> +		return;
> +
> +	while (!ug_is_txfifo_ready() && count--)
> +		barrier();
> +	if (count)
> +		ug_raw_putc(ch);
> +}
> +
> +void ug_console_write(const char *buf, int len)
> +{
> +	char *b = (char *)buf;
> +
> +	while (len--) {
> +		if (*b == '\n')
> +			ug_putc('\r');
> +		ug_putc(*b++);
> +	}
> +}
> +
> +static int ug_is_adapter_present(void)
> +{
> +	if (!ug_io_base)
> +		return 0;
> +	return ug_io_transaction(0x90000000) == 0x04700000;
> +}
> +
> +static void *ug_grab_exi_io_base(void)
> +{
> +	u32 v;
> +	void *devp;
> +
> +	devp = find_node_by_compatible(NULL, "nintendo,flipper-exi");
> +	if (devp == NULL)
> +		goto err_out;
> +	if (getprop(devp, "virtual-reg", &v, sizeof(v)) != sizeof(v))
> +		goto err_out;
> +
> +	return (void *)v;
> +
> +err_out:
> +	return NULL;
> +}
> +
> +void *ug_probe(void)
> +{
> +	void *exi_io_base;
> +	int i;
> +
> +	exi_io_base = ug_grab_exi_io_base();
> +	if (!exi_io_base)
> +		return NULL;
> +
> +	/* look for a usbgecko on memcard slots A and B */
> +	for (i = 0; i < 2; i++) {
> +		ug_io_base = exi_io_base + 0x14 * i;
> +		if (ug_is_adapter_present())
> +			break;
> +	}
> +	if (i == 2)
> +		ug_io_base = NULL;
> +	return ug_io_base;
> +}
> +
> diff --git a/arch/powerpc/boot/ugecon.h b/arch/powerpc/boot/ugecon.h
> new file mode 100644
> index 0000000..4373753
> --- /dev/null
> +++ b/arch/powerpc/boot/ugecon.h
> @@ -0,0 +1,24 @@
> +/*
> + * arch/powerpc/boot/ugecon.h
> + *
> + * USB Gecko early bootwrapper console.
> + * Copyright (C) 2008-2009 The GameCube Linux Team
> + * Copyright (C) 2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#ifndef __UGECON_H
> +#define __UGECON_H
> +
> +extern void *ug_probe(void);
> +
> +extern void ug_putc(char ch);
> +extern void ug_console_write(const char *buf, int len);
> +
> +#endif /* __UGECON_H */
> +
> -- 
> 1.6.3.3
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [RFC PATCH v2 02/11] powerpc: gamecube: device tree
From: Segher Boessenkool @ 2009-12-01 18:29 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <1259441037-15725-3-git-send-email-albert_herranz@yahoo.es>

> Add a device tree source file for the Nintendo GameCube video game  
> console.
>
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> ---
> v1 -> v2
> - Document new bindings in Documentation/powerpc/dts-bindings.
>   Suggestion by Grant Likely.
> - Use same form for model property and compatible properties on the  
> root
>   node.  Suggestion by Grant Likely.
> - Drop the model property in the soc node.  Suggestion by Grant  
> Likely.
> - Move interrupt-parent to the soc node instead of explicitly  
> adding it to
>   each child node.  Suggestion by Grant Likely.
> - Declare all available memory and deal with the fb area in the  
> platform
>   code. Suggestion by Segher Boessenkool.
> - Transform the "auxram" node into the "dsp" node, create an  
> "auxram" node
>   within the "dsp" node. Suggestion by Segher Boessenkool.
> - Rename the "soc" node to "flipper". Suggestion by Benjamin  
> Herrenschmidt.
> - Remove the usbgecko node from the device tree and autodetect it in
>   platform code. Suggestion by Segher Boessenkool.
> - Remove clock-frequency property from the soc node.
>   Suggestion by Segher Boessenkool.
> - Create a flipper-processor-interface node and place flipper-pic  
> into it.
>   Suggestion by Segher Boessenkool.
> - Remove #interrupt-cells from the flipper node.
>   Suggestion by Segher Boessenkool.
> - Massive cleanups. Suggestions by Segher Boessenkool.
>
>  .../powerpc/dts-bindings/nintendo/gamecube.txt     |  109 +++++++++ 
> ++++++++++
>  arch/powerpc/boot/dts/gamecube.dts                 |  114 +++++++++ 
> +++++++++++
>  2 files changed, 223 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/powerpc/dts-bindings/nintendo/ 
> gamecube.txt
>  create mode 100644 arch/powerpc/boot/dts/gamecube.dts
>
> diff --git a/Documentation/powerpc/dts-bindings/nintendo/ 
> gamecube.txt b/Documentation/powerpc/dts-bindings/nintendo/ 
> gamecube.txt
> new file mode 100644
> index 0000000..b558585
> --- /dev/null
> +++ b/Documentation/powerpc/dts-bindings/nintendo/gamecube.txt
> @@ -0,0 +1,109 @@
> +
> +Nintendo GameCube device tree
> +=============================
> +
> +1) The "flipper" node
> +
> +  This node represents the multi-function "Flipper" chip, which  
> packages
> +  many of the devices found in the Nintendo GameCube.
> +
> +  Required properties:
> +
> +   - compatible : Should be "nintendo,flipper"
> +
> +1.a) The Video Interface (VI) node
> +
> +  Represents the interface between the graphics processor and a  
> external
> +  video encoder.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-vi"
> +   - reg : should contain the VI registers location and length
> +   - interrupts : should contain the VI interrupt
> +
> +1.b) The Processor Interface (PI) node
> +
> +  Represents the data and control interface between the main  
> processor
> +  and graphics and audio processor.
> +
> +  Required properties:
> +
> +  - compatible : should be "nintendo,flipper-pi"
> +  - reg : should contain the PI registers location and length
> +
> +1.b.i) The "Flipper" interrupt controller node
> +
> +  Represents the interrupt controller within the "Flipper" chip.
> +  The node for the "Flipper" interrupt controller must be placed  
> under
> +  the PI node.
> +
> +  Required properties:
> +
> +  - compatible : should be "nintendo,flipper-pic"
> +
> +1.c) The Digital Signal Procesor (DSP) node
> +
> +  Represents the digital signal processor interface, designed to  
> offload
> +  audio related tasks.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-dsp"
> +   - reg : should contain the DSP registers location and length
> +   - interrupts : should contain the DSP interrupt
> +
> +1.c.i) The Auxiliary RAM (ARAM) node
> +
> +  Represents the non cpu-addressable ram designed mainly to store  
> audio
> +  related information.
> +  The ARAM node must be placed under the DSP node.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-aram"
> +   - reg : should contain the ARAM start (zero-based) and length
> +
> +1.d) The Disk Interface (DI) node
> +
> +  Represents the interface used to communicate with mass storage  
> devices.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-di"
> +   - reg : should contain the DI registers location and length
> +   - interrupts : should contain the DI interrupt
> +
> +1.e) The Audio Interface (AI) node
> +
> +  Represents the interface to the external 16-bit stereo digital- 
> to-analog
> +  converter.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-ai"
> +   - reg : should contain the AI registers location and length
> +   - interrupts : should contain the AI interrupt
> +
> +1.f) The Serial Interface (SI) node
> +
> +  Represents the interface to the four single bit serial interfaces.
> +  The SI is a proprietary serial interface used normally to  
> control gamepads.
> +  It's NOT a RS232-type interface.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-si"
> +   - reg : should contain the SI registers location and length
> +   - interrupts : should contain the SI interrupt
> +
> +1.g) The External Interface (EXI) node
> +
> +  Represents the multi-channel SPI-like interface.
> +
> +  Required properties:
> +
> +   - compatible : should be "nintendo,flipper-exi"
> +   - reg : should contain the EXI registers location and length
> +   - interrupts : should contain the EXI interrupt
> +
> diff --git a/arch/powerpc/boot/dts/gamecube.dts b/arch/powerpc/boot/ 
> dts/gamecube.dts
> new file mode 100644
> index 0000000..ef3be0e
> --- /dev/null
> +++ b/arch/powerpc/boot/dts/gamecube.dts
> @@ -0,0 +1,114 @@
> +/*
> + * arch/powerpc/boot/dts/gamecube.dts
> + *
> + * Nintendo GameCube platform device tree source
> + * Copyright (C) 2007-2009 The GameCube Linux Team
> + * Copyright (C) 2007,2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +/dts-v1/;
> +
> +/ {
> +	model = "nintendo,gamecube";
> +	compatible = "nintendo,gamecube";
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +
> +	chosen {
> +		bootargs = "root=/dev/gcnsda2 rootwait udbg-immortal";
> +	};
> +
> +	memory {
> +		device_type = "memory";
> +		reg = <0x00000000 0x01800000>;
> +	};
> +
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		PowerPC,gekko@0 {
> +			device_type = "cpu";
> +			reg = <0>;
> +			clock-frequency = <486000000>; /* 486MHz */
> +			bus-frequency = <162000000>; /* 162MHz core-to-bus 3x */
> +			timebase-frequency = <40500000>; /* 162MHz / 4 */
> +			i-cache-line-size = <32>;
> +			d-cache-line-size = <32>;
> +			i-cache-size = <32768>;
> +			d-cache-size = <32768>;
> +		};
> +	};
> +
> +	/* devices contained int the flipper chipset */
> +	flipper {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		compatible = "nintendo,flipper";
> +		ranges = <0x0c000000 0x0c000000 0x00010000>;
> +		interrupt-parent = <&PIC>;
> +
> +		video@0c002000 {
> +			compatible = "nintendo,flipper-vi";
> +			reg = <0x0c002000 0x100>;
> +			interrupts = <8>;
> +		};
> +
> +		processor-interface@0c003000 {
> +			compatible = "nintendo,flipper-pi";
> +			reg = <0x0c003000 0x100>;
> +
> +			PIC: pic {
> +				#interrupt-cells = <1>;
> +				compatible = "nintendo,flipper-pic";
> +				interrupt-controller;
> +			};
> +		};
> +
> +		dsp@0c005000 {
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +			compatible = "nintendo,flipper-dsp";
> +			reg = <0x0c005000 0x200>;
> +			interrupts = <6>;
> +
> +			memory@0 {
> +				compatible = "nintendo,flipper-aram";
> +				reg = <0 0x1000000>;	/* 16MB */
> +			};
> +		};
> +
> +		disk@0c006000 {
> +			compatible = "nintendo,flipper-di";
> +			reg = <0x0c006000 0x40>;
> +			interrupts = <2>;
> +		};
> +
> +		audio@0c006c00 {
> +			compatible = "nintendo,flipper-ai";
> +			reg = <0x0c006c00 0x20>;
> +			interrupts = <6>;
> +		};
> +
> +		gamepad-controller@0c006400 {
> +			compatible = "nintendo,flipper-si";
> +			reg = <0x0c006400 0x100>;
> +			interrupts = <3>;
> +		};
> +
> +		/* External Interface bus */
> +		exi@0c006800 {
> +			compatible = "nintendo,flipper-exi";
> +			reg = <0x0c006800 0x40>;
> +			virtual-reg = <0x0c006800>;
> +			interrupts = <4>;
> +		};
> +        };
> +};
> +
> -- 
> 1.6.3.3
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [RFC PATCH v2 03/11] powerpc: gamecube: bootwrapper bits
From: Segher Boessenkool @ 2009-12-01 18:31 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <1259441037-15725-4-git-send-email-albert_herranz@yahoo.es>

> Add support for the Nintendo GameCube video game console to the  
> powerpc
> bootwrapper.
>
> dtbImage.gamecube is a wrapped image that contains a flat device tree,
> an entry point compatible with SDload, and an optional initrd.
>
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> ---
> v1 -> v2
> - Use a separate asm file for the entry point code.
>   Suggestion by Segher Boessenkool and Benjamin Herrenschmidt.
> - Do not make assumptions about the state of the cache and MMU on
>   entry, eliminating dependencies on a particular bootloader.
>   Suggestion by Segher Boessenkool.
> - Use consistently the same (easier to read) form of bcl to load the
>   next instruction address in LR. Suggestion by Segher Boessenkool.
> - Identity map I/O memory too to avoid confusions.
>   Suggestion by Segher Boessenkool.
> - Probe dinamically for usbgecko. Suggestion by Segher Boessenkool.
>
>  arch/powerpc/boot/Makefile        |    4 +-
>  arch/powerpc/boot/gamecube-head.S |  111 ++++++++++++++++++++++++++ 
> +++++++++++
>  arch/powerpc/boot/gamecube.c      |   35 ++++++++++++
>  arch/powerpc/boot/wrapper         |    4 +
>  4 files changed, 153 insertions(+), 1 deletions(-)
>  create mode 100644 arch/powerpc/boot/gamecube-head.S
>  create mode 100644 arch/powerpc/boot/gamecube.c
>
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 44bce21..3e70aab 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -76,7 +76,8 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c  
> cuboot-83xx.c cuboot-85xx.c holly.c
>  		cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
>  		cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
>  		virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
> -		cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c
> +		cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c \
> +		gamecube-head.S gamecube.c
>  src-boot := $(src-wlib) $(src-plat) empty.c
>
>  src-boot := $(addprefix $(obj)/, $(src-boot))
> @@ -254,6 +255,7 @@ image-$(CONFIG_KSI8560)			+= cuImage.ksi8560
>  image-$(CONFIG_STORCENTER)		+= cuImage.storcenter
>  image-$(CONFIG_MPC7448HPC2)		+= cuImage.mpc7448hpc2
>  image-$(CONFIG_PPC_C2K)			+= cuImage.c2k
> +image-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
>
>  # Board port in arch/powerpc/platform/amigaone/Kconfig
>  image-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
> diff --git a/arch/powerpc/boot/gamecube-head.S b/arch/powerpc/boot/ 
> gamecube-head.S
> new file mode 100644
> index 0000000..65a9b2a
> --- /dev/null
> +++ b/arch/powerpc/boot/gamecube-head.S
> @@ -0,0 +1,111 @@
> +/*
> + * arch/powerpc/boot/gamecube-head.S
> + *
> + * Nintendo GameCube bootwrapper entry.
> + * Copyright (C) 2004-2009 The GameCube Linux Team
> + * Copyright (C) 2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#include "ppc_asm.h"
> +
> +/*
> + * The entry code does no assumptions regarding:
> + * - if the data and instruction caches are enabled or not
> + * - if the MMU is enabled or not
> + *
> + * We enable the caches if not already enabled, enable the MMU  
> with an
> + * identity mapping scheme and jump to the start code.
> + */
> +
> +	.text
> +
> +	.globl _zimage_start
> +_zimage_start:
> +
> +	/* turn the MMU off */
> +	mfmsr	9
> +	rlwinm	9, 9, 0, ~((1<<4)|(1<<5)) /* MSR_DR|MSR_IR */
> +	bcl	20, 31, 1f
> +1:
> +	mflr	8
> +	clrlwi	8, 8, 3		/* convert to a real address */
> +	addi	8, 8, _mmu_off - 1b
> +	mtsrr0	8
> +	mtsrr1	9
> +	rfi
> +_mmu_off:
> +	/* MMU disabled */
> +
> +	/* setup BATs */
> +	isync
> +	li      8, 0
> +	mtspr	0x210, 8	/* IBAT0U */
> +	mtspr	0x212, 8	/* IBAT1U */
> +	mtspr	0x214, 8	/* IBAT2U */
> +	mtspr	0x216, 8	/* IBAT3U */
> +	mtspr	0x218, 8	/* DBAT0U */
> +	mtspr	0x21a, 8	/* DBAT1U */
> +	mtspr	0x21c, 8	/* DBAT2U */
> +	mtspr	0x21e, 8	/* DBAT3U */
> +
> +	li	8, 0x01ff	/* first 16MiB */
> +	li	9, 0x0002	/* rw */
> +	mtspr	0x211, 9	/* IBAT0L */
> +	mtspr	0x210, 8	/* IBAT0U */
> +	mtspr	0x219, 9	/* DBAT0L */
> +	mtspr	0x218, 8	/* DBAT0U */
> +
> +	lis	8, 0x0c00	/* I/O mem */
> +	ori	8, 8, 0x3ff	/* 32MiB */
> +	lis	9, 0x0c00
> +	ori	9, 9, 0x002a	/* uncached, guarded, rw */
> +	mtspr	0x21b, 9	/* DBAT1L */
> +	mtspr	0x21a, 8	/* DBAT1U */
> +
> +	lis	8, 0x0100	/* next 8MiB */
> +	ori	8, 8, 0x00ff	/* 8MiB */
> +	lis	9, 0x0100
> +	ori	9, 9, 0x0002	/* rw */
> +	mtspr	0x215, 9	/* IBAT2L */
> +	mtspr	0x214, 8	/* IBAT2U */
> +	mtspr	0x21d, 9	/* DBAT2L */
> +	mtspr	0x21c, 8	/* DBAT2U */
> +
> +	/* enable and invalidate the caches if not already enabled */
> +	mfspr	8, 0x3f0	/* HID0 */
> +	andi.	0, 8, (1<<15)		/* HID0_ICE */
> +	bne	1f
> +	ori	8, 8, (1<<15)|(1<<11)	/* HID0_ICE|HID0_ICFI*/
> +1:
> +	andi.	0, 8, (1<<14)		/* HID0_DCE */
> +	bne	1f
> +	ori	8, 8, (1<<14)|(1<<10)	/* HID0_DCE|HID0_DCFI*/
> +1:
> +	mtspr	0x3f0, 8	/* HID0 */
> +	isync
> +
> +	/* initialize arguments */
> +	li	3, 0
> +	li	4, 0
> +	li	5, 0
> +
> +	/* turn the MMU on */
> +	bcl	20, 31, 1f
> +1:
> +	mflr	8
> +	addi	8, 8, _mmu_on - 1b
> +	mfmsr	9
> +	ori	9, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */
> +	mtsrr0	8
> +	mtsrr1	9
> +	sync
> +	rfi
> +_mmu_on:
> +	b _zimage_start_lib
> +
> diff --git a/arch/powerpc/boot/gamecube.c b/arch/powerpc/boot/ 
> gamecube.c
> new file mode 100644
> index 0000000..28ae705
> --- /dev/null
> +++ b/arch/powerpc/boot/gamecube.c
> @@ -0,0 +1,35 @@
> +/*
> + * arch/powerpc/boot/gamecube.c
> + *
> + * Nintendo GameCube bootwrapper support
> + * Copyright (C) 2004-2009 The GameCube Linux Team
> + * Copyright (C) 2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#include <stddef.h>
> +#include "stdio.h"
> +#include "types.h"
> +#include "io.h"
> +#include "ops.h"
> +
> +#include "ugecon.h"
> +
> +BSS_STACK(8192);
> +
> +void platform_init(unsigned long r3, unsigned long r4, unsigned  
> long r5)
> +{
> +	u32 heapsize = 16*1024*1024 - (u32)_end;
> +
> +	simple_alloc_init(_end, heapsize, 32, 64);
> +	fdt_init(_dtb_start);
> +
> +	if (ug_probe())
> +		console_ops.write = ug_console_write;
> +}
> +
> diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
> index ac9e9a5..5b9206f 100755
> --- a/arch/powerpc/boot/wrapper
> +++ b/arch/powerpc/boot/wrapper
> @@ -230,6 +230,10 @@ xpedite52*)
>      link_address='0x1400000'
>      platformo=$object/cuboot-85xx.o
>      ;;
> +gamecube)
> +    link_address='0x600000'
> +    platformo="$object/$platform-head.o $object/$platform.o"
> +    ;;
>  esac
>
>  vmz="$tmpdir/`basename \"$kernel\"`.$ext"
> -- 
> 1.6.3.3
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [RFC PATCH v2 07/11] powerpc: gamecube/wii: udbg support for usbgecko
From: Segher Boessenkool @ 2009-12-01 18:33 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <1259441037-15725-8-git-send-email-albert_herranz@yahoo.es>

> Add support for using the USB Gecko adapter via the udbg facility on
> the Nintendo GameCube and Wii video game consoles.
> The USB Gecko is a 3rd party memory card interface adapter that  
> provides
> a EXI (External Interface) to USB serial converter.
>
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> ---
> v1 -> v2
> - Get rid of 0-#ifdef'ed code. Suggestion by Segher Boessenkool.
> - Probe dinamically for usbgecko. Suggestion by Segher Boessenkool.
> - Adapt to updated device tree.
>
>  arch/powerpc/platforms/embedded6xx/Kconfig         |   13 +
>  arch/powerpc/platforms/embedded6xx/Makefile        |    1 +
>  arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |  272 +++++++++ 
> +++++++++++
>  arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |   30 +++
>  4 files changed, 316 insertions(+), 0 deletions(-)
>  create mode 100644 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
>  create mode 100644 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
>
> diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/ 
> powerpc/platforms/embedded6xx/Kconfig
> index 97a2dbc..464e414 100644
> --- a/arch/powerpc/platforms/embedded6xx/Kconfig
> +++ b/arch/powerpc/platforms/embedded6xx/Kconfig
> @@ -94,3 +94,16 @@ config MPC10X_STORE_GATHERING
>  config GAMECUBE_COMMON
>  	bool
>
> +config USBGECKO_UDBG
> +	bool "USB Gecko udbg console for the Nintendo GameCube/Wii"
> +	depends on GAMECUBE_COMMON
> +	help
> +	  If you say yes to this option, support will be included for the
> +	  USB Gecko adapter as an udbg console.
> +	  The USB Gecko is a EXI to USB Serial converter that can be plugged
> +	  into a memcard slot in the Nintendo GameCube/Wii.
> +
> +	  This driver bypasses the EXI layer completely.
> +
> +	  If in doubt, say N here.
> +
> diff --git a/arch/powerpc/platforms/embedded6xx/Makefile b/arch/ 
> powerpc/platforms/embedded6xx/Makefile
> index 0773c08..0ab7492 100644
> --- a/arch/powerpc/platforms/embedded6xx/Makefile
> +++ b/arch/powerpc/platforms/embedded6xx/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_STORCENTER)	+= storcenter.o
>  obj-$(CONFIG_PPC_HOLLY)		+= holly.o
>  obj-$(CONFIG_PPC_PRPMC2800)	+= prpmc2800.o
>  obj-$(CONFIG_PPC_C2K)		+= c2k.o
> +obj-$(CONFIG_USBGECKO_UDBG)	+= usbgecko_udbg.o
> diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c b/ 
> arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
> new file mode 100644
> index 0000000..581ce61
> --- /dev/null
> +++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
> @@ -0,0 +1,272 @@
> +/*
> + * arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
> + *
> + * udbg serial input/output routines for the USB Gecko adapter.
> + * Copyright (C) 2008-2009 The GameCube Linux Team
> + * Copyright (C) 2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#include <asm/io.h>
> +#include <asm/prom.h>
> +#include <asm/udbg.h>
> +
> +#include <mm/mmu_decl.h>
> +
> +#include "usbgecko_udbg.h"
> +
> +
> +#define EXI_CLK_32MHZ           5
> +
> +#define EXI_CSR                 0x00
> +#define   EXI_CSR_CLKMASK       (0x7<<4)
> +#define     EXI_CSR_CLK_32MHZ   (EXI_CLK_32MHZ<<4)
> +#define   EXI_CSR_CSMASK        (0x7<<7)
> +#define     EXI_CSR_CS_0        (0x1<<7)  /* Chip Select 001 */
> +
> +#define EXI_CR                  0x0c
> +#define   EXI_CR_TSTART         (1<<0)
> +#define   EXI_CR_WRITE		(1<<2)
> +#define   EXI_CR_READ_WRITE     (2<<2)
> +#define   EXI_CR_TLEN(len)      (((len)-1)<<4)
> +
> +#define EXI_DATA                0x10
> +
> +#define UG_READ_ATTEMPTS	100
> +#define UG_WRITE_ATTEMPTS	100
> +
> +
> +static void __iomem *ug_io_base;
> +
> +/*
> + * Performs one input/output transaction between the exi host and  
> the usbgecko.
> + */
> +static u32 ug_io_transaction(u32 in)
> +{
> +	u32 __iomem *csr_reg = ug_io_base + EXI_CSR;
> +	u32 __iomem *data_reg = ug_io_base + EXI_DATA;
> +	u32 __iomem *cr_reg = ug_io_base + EXI_CR;
> +	u32 csr, data, cr;
> +
> +	/* select */
> +	csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
> +	out_be32(csr_reg, csr);
> +
> +	/* read/write */
> +	data = in;
> +	out_be32(data_reg, data);
> +	cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
> +	out_be32(cr_reg, cr);
> +
> +	while (in_be32(cr_reg) & EXI_CR_TSTART)
> +		barrier();
> +
> +	/* deselect */
> +	out_be32(csr_reg, 0);
> +
> +	/* result */
> +	data = in_be32(data_reg);
> +
> +	return data;
> +}
> +
> +/*
> + * Returns true if an usbgecko adapter is found.
> + */
> +static int ug_is_adapter_present(void)
> +{
> +	if (!ug_io_base)
> +		return 0;
> +
> +	return ug_io_transaction(0x90000000) == 0x04700000;
> +}
> +
> +/*
> + * Returns true if the TX fifo is ready for transmission.
> + */
> +static int ug_is_txfifo_ready(void)
> +{
> +	return ug_io_transaction(0xc0000000) & 0x04000000;
> +}
> +
> +/*
> + * Tries to transmit a character.
> + * If the TX fifo is not ready the result is undefined.
> + */
> +static void ug_raw_putc(char ch)
> +{
> +	ug_io_transaction(0xb0000000 | (ch << 20));
> +}
> +
> +/*
> + * Transmits a character.
> + * It silently fails if the TX fifo is not ready after a number of  
> retries.
> + */
> +static void ug_putc(char ch)
> +{
> +	int count = UG_WRITE_ATTEMPTS;
> +
> +	if (!ug_io_base)
> +		return;
> +
> +	if (ch == '\n')
> +		ug_putc('\r');
> +
> +	while (!ug_is_txfifo_ready() && count--)
> +		barrier();
> +	if (count)
> +		ug_raw_putc(ch);
> +}
> +
> +/*
> + * Returns true if the RX fifo is ready for transmission.
> + */
> +static int ug_is_rxfifo_ready(void)
> +{
> +	return ug_io_transaction(0xd0000000) & 0x04000000;
> +}
> +
> +/*
> + * Tries to receive a character.
> + * If a character is unavailable the function returns -1.
> + */
> +static int ug_raw_getc(void)
> +{
> +	u32 data = ug_io_transaction(0xa0000000);
> +	if (data & 0x08000000)
> +		return (data >> 16) & 0xff;
> +	else
> +		return -1;
> +}
> +
> +/*
> + * Receives a character.
> + * It fails if the RX fifo is not ready after a number of retries.
> + */
> +static int ug_getc(void)
> +{
> +	int count = UG_READ_ATTEMPTS;
> +
> +	if (!ug_io_base)
> +		return -1;
> +
> +	while (!ug_is_rxfifo_ready() && count--)
> +		barrier();
> +	return ug_raw_getc();
> +}
> +
> +/*
> + * udbg functions.
> + *
> + */
> +
> +/*
> + * Transmits a character.
> + */
> +void ug_udbg_putc(char ch)
> +{
> +	ug_putc(ch);
> +}
> +
> +/*
> + * Receives a character. Waits until a character is available.
> + */
> +static int ug_udbg_getc(void)
> +{
> +	int ch;
> +
> +	while ((ch = ug_getc()) == -1)
> +		barrier();
> +	return ch;
> +}
> +
> +/*
> + * Receives a character. If a character is not available, returns -1.
> + */
> +static int ug_udbg_getc_poll(void)
> +{
> +	if (!ug_is_rxfifo_ready())
> +		return -1;
> +	return ug_getc();
> +}
> +
> +/*
> + * Retrieves and prepares the virtual address needed to access the  
> hardware.
> + */
> +static void __iomem *ug_udbg_setup_exi_io_base(struct device_node  
> *np)
> +{
> +	void __iomem *exi_io_base = NULL;
> +	phys_addr_t paddr;
> +	const unsigned int *reg;
> +
> +	reg = of_get_property(np, "reg", NULL);
> +	if (reg) {
> +		paddr = of_translate_address(np, reg);
> +		if (paddr)
> +			exi_io_base = ioremap(paddr, reg[1]);
> +	}
> +	return exi_io_base;
> +}
> +
> +/*
> + * Checks if a USB Gecko adapter is inserted in any memory card slot.
> + */
> +static void __iomem *ug_udbg_probe(void __iomem *exi_io_base)
> +{
> +	int i;
> +
> +	/* look for a usbgecko on memcard slots A and B */
> +	for (i = 0; i < 2; i++) {
> +		ug_io_base = exi_io_base + 0x14 * i;
> +		if (ug_is_adapter_present())
> +			break;
> +	}
> +	if (i == 2)
> +		ug_io_base = NULL;
> +	return ug_io_base;
> +
> +}
> +
> +/*
> + * USB Gecko udbg support initialization.
> + */
> +void __init ug_udbg_init(void)
> +{
> +	struct device_node *np;
> +	void __iomem *exi_io_base;
> +
> +	if (ug_io_base)
> +		udbg_printf("%s: early -> final\n", __func__);
> +
> +	np = of_find_compatible_node(NULL, NULL, "nintendo,flipper-exi");
> +	if (!np) {
> +		udbg_printf("%s: EXI node not found\n", __func__);
> +		goto done;
> +	}
> +
> +	exi_io_base = ug_udbg_setup_exi_io_base(np);
> +	if (!exi_io_base) {
> +		udbg_printf("%s: failed to setup EXI io base\n", __func__);
> +		goto done;
> +	}
> +
> +	if (!ug_udbg_probe(exi_io_base)) {
> +		udbg_printf("usbgecko_udbg: not found\n");
> +		iounmap(exi_io_base);
> +	} else {
> +		udbg_putc = ug_udbg_putc;
> +		udbg_getc = ug_udbg_getc;
> +		udbg_getc_poll = ug_udbg_getc_poll;
> +		udbg_printf("usbgecko_udbg: ready\n");
> +	}
> +
> +done:
> +	if (np)
> +		of_node_put(np);
> +	return;
> +}
> diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h b/ 
> arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
> new file mode 100644
> index 0000000..3929de3
> --- /dev/null
> +++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
> @@ -0,0 +1,30 @@
> +/*
> + * arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
> + *
> + * udbg serial input/output routines for the USB Gecko adapter.
> + * Copyright (C) 2008-2009 The GameCube Linux Team
> + * Copyright (C) 2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#ifndef __USBGECKO_UDBG_H
> +#define __USBGECKO_UDBG_H
> +
> +#ifdef CONFIG_USBGECKO_UDBG
> +
> +extern void __init ug_udbg_init(void);
> +
> +#else
> +
> +static inline void __init ug_udbg_init(void)
> +{
> +}
> +
> +#endif /* CONFIG_USBGECKO_UDBG */
> +
> +#endif /* __USBGECKO_UDBG_H */
> -- 
> 1.6.3.3
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [RFC PATCH v2 09/11] powerpc: gamecube/wii: flipper interrupt controller support
From: Segher Boessenkool @ 2009-12-01 18:35 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <1259441037-15725-10-git-send-email-albert_herranz@yahoo.es>

> Add support for the interrupt controller included in the "Flipper"
> chipset of the Nintendo GameCube video game console.
> The same interrupt controller is also present in the "Hollywood"  
> chipset
> of the Nintendo Wii.
>
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> ---
> v1 -> v2
> - Build always Flipper interrupt controller when GAMECUBE_COMMON and
>   get rid of FLIPPER_PIC option. Suggestion by Grant Likely.
> - Use NO_IRQ instead of -1. Suggestion by Benjamin Herrenschmidt.
> - Write 0xffffffff instead of ~0 to clear interrupts.
>   Suggestion by Segher Boessenkool.
> - Use __fls instead of open coded asm. Suggestion by Segher  
> Boessenkool.
> - Use a write instead of a read/modify/write to ack interrupts.
>   Suggestion by Segher Boessenkool and Benjamin Herrenschmidt.
> - Use name instead of typename for struct irq_chip.
> - Adapt to updated device tree.
>
>  arch/powerpc/platforms/embedded6xx/Makefile      |    1 +
>  arch/powerpc/platforms/embedded6xx/flipper-pic.c |  263 +++++++++++ 
> +++++++++++
>  arch/powerpc/platforms/embedded6xx/flipper-pic.h |   25 ++
>  3 files changed, 289 insertions(+), 0 deletions(-)
>  create mode 100644 arch/powerpc/platforms/embedded6xx/flipper-pic.c
>  create mode 100644 arch/powerpc/platforms/embedded6xx/flipper-pic.h
>
> diff --git a/arch/powerpc/platforms/embedded6xx/Makefile b/arch/ 
> powerpc/platforms/embedded6xx/Makefile
> index 0ab7492..b80f47c 100644
> --- a/arch/powerpc/platforms/embedded6xx/Makefile
> +++ b/arch/powerpc/platforms/embedded6xx/Makefile
> @@ -8,3 +8,4 @@ obj-$(CONFIG_PPC_HOLLY)		+= holly.o
>  obj-$(CONFIG_PPC_PRPMC2800)	+= prpmc2800.o
>  obj-$(CONFIG_PPC_C2K)		+= c2k.o
>  obj-$(CONFIG_USBGECKO_UDBG)	+= usbgecko_udbg.o
> +obj-$(CONFIG_GAMECUBE_COMMON)	+= flipper-pic.o
> diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.c b/ 
> arch/powerpc/platforms/embedded6xx/flipper-pic.c
> new file mode 100644
> index 0000000..d596328
> --- /dev/null
> +++ b/arch/powerpc/platforms/embedded6xx/flipper-pic.c
> @@ -0,0 +1,263 @@
> +/*
> + * arch/powerpc/platforms/embedded6xx/flipper-pic.c
> + *
> + * Nintendo GameCube/Wii "Flipper" interrupt controller support.
> + * Copyright (C) 2004-2009 The GameCube Linux Team
> + * Copyright (C) 2007,2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +#define DRV_MODULE_NAME "flipper-pic"
> +#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/irq.h>
> +#include <linux/of.h>
> +#include <asm/io.h>
> +
> +#include "flipper-pic.h"
> +
> +#define FLIPPER_NR_IRQS		32
> +
> +/*
> + * Each interrupt has a corresponding bit in both
> + * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
> + *
> + * Enabling/disabling an interrupt line involves setting/clearing
> + * the corresponding bit in IMR.
> + * Except for the RSW interrupt, all interrupts get deasserted  
> automatically
> + * when the source deasserts the interrupt.
> + */
> +#define FLIPPER_ICR		0x00
> +#define FLIPPER_ICR_RSS		(1<<16) /* reset switch state */
> +
> +#define FLIPPER_IMR		0x04
> +
> +#define FLIPPER_RESET		0x24
> +
> +
> +/*
> + * IRQ chip hooks.
> + *
> + */
> +
> +static void flipper_pic_mask_and_ack(unsigned int virq)
> +{
> +	int irq = virq_to_hw(virq);
> +	void __iomem *io_base = get_irq_chip_data(virq);
> +	u32 mask = 1 << irq;
> +
> +	clrbits32(io_base + FLIPPER_IMR, mask);
> +	/* this is at least needed for RSW */
> +	out_be32(io_base + FLIPPER_ICR, mask);
> +}
> +
> +static void flipper_pic_ack(unsigned int virq)
> +{
> +	int irq = virq_to_hw(virq);
> +	void __iomem *io_base = get_irq_chip_data(virq);
> +
> +	/* this is at least needed for RSW */
> +	out_be32(io_base + FLIPPER_ICR, 1 << irq);
> +}
> +
> +static void flipper_pic_mask(unsigned int virq)
> +{
> +	int irq = virq_to_hw(virq);
> +	void __iomem *io_base = get_irq_chip_data(virq);
> +
> +	clrbits32(io_base + FLIPPER_IMR, 1 << irq);
> +}
> +
> +static void flipper_pic_unmask(unsigned int virq)
> +{
> +	int irq = virq_to_hw(virq);
> +	void __iomem *io_base = get_irq_chip_data(virq);
> +
> +	setbits32(io_base + FLIPPER_IMR, 1 << irq);
> +}
> +
> +
> +static struct irq_chip flipper_pic = {
> +	.name		= "flipper-pic",
> +	.ack		= flipper_pic_ack,
> +	.mask_ack	= flipper_pic_mask_and_ack,
> +	.mask		= flipper_pic_mask,
> +	.unmask		= flipper_pic_unmask,
> +};
> +
> +/*
> + * IRQ host hooks.
> + *
> + */
> +
> +static struct irq_host *flipper_irq_host;
> +
> +static int flipper_pic_map(struct irq_host *h, unsigned int virq,
> +			   irq_hw_number_t hwirq)
> +{
> +	set_irq_chip_data(virq, h->host_data);
> +	get_irq_desc(virq)->status |= IRQ_LEVEL;
> +	set_irq_chip_and_handler(virq, &flipper_pic, handle_level_irq);
> +	return 0;
> +}
> +
> +static void flipper_pic_unmap(struct irq_host *h, unsigned int irq)
> +{
> +	set_irq_chip_data(irq, NULL);
> +	set_irq_chip(irq, NULL);
> +}
> +
> +static int flipper_pic_match(struct irq_host *h, struct  
> device_node *np)
> +{
> +	return 1;
> +}
> +
> +
> +static struct irq_host_ops flipper_irq_host_ops = {
> +	.map = flipper_pic_map,
> +	.unmap = flipper_pic_unmap,
> +	.match = flipper_pic_match,
> +};
> +
> +/*
> + * Platform hooks.
> + *
> + */
> +
> +static void __flipper_quiesce(void __iomem *io_base)
> +{
> +	/* mask and ack all IRQs */
> +	out_be32(io_base + FLIPPER_IMR, 0x00000000);
> +	out_be32(io_base + FLIPPER_ICR, 0xffffffff);
> +}
> +
> +struct irq_host * __init flipper_pic_init(struct device_node *np)
> +{
> +	struct device_node *pi;
> +	struct irq_host *irq_host = NULL;
> +	struct resource res;
> +	void __iomem *io_base;
> +	int retval;
> +
> +	pi = of_get_parent(np);
> +	if (!pi) {
> +		pr_err("no parent found\n");
> +		goto out;
> +	}
> +	if (!of_device_is_compatible(pi, "nintendo,flipper-pi")) {
> +		pr_err("unexpected parent compatible\n");
> +		goto out;
> +	}
> +
> +	retval = of_address_to_resource(pi, 0, &res);
> +	if (retval) {
> +		pr_err("no io memory range found\n");
> +		goto out;
> +	}
> +	io_base = ioremap(res.start, resource_size(&res));
> +
> +	pr_info("controller at 0x%08x mapped to 0x%p\n", res.start,  
> io_base);
> +
> +	__flipper_quiesce(io_base);
> +
> +	irq_host = irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, FLIPPER_NR_IRQS,
> +				  &flipper_irq_host_ops, -1);
> +	if (!irq_host) {
> +		pr_err("failed to allocate irq_host\n");
> +		return NULL;
> +	}
> +
> +	irq_host->host_data = io_base;
> +
> +out:
> +	return irq_host;
> +}
> +
> +unsigned int flipper_pic_get_irq(void)
> +{
> +	void __iomem *io_base = flipper_irq_host->host_data;
> +	int irq;
> +	u32 irq_status;
> +
> +	irq_status = in_be32(io_base + FLIPPER_ICR) &
> +		     in_be32(io_base + FLIPPER_IMR);
> +	if (irq_status == 0)
> +		return NO_IRQ;	/* no more IRQs pending */
> +
> +	irq = __ffs(irq_status);
> +	return irq_linear_revmap(flipper_irq_host, irq);
> +}
> +
> +/*
> + * Probe function.
> + *
> + */
> +
> +void __init flipper_pic_probe(void)
> +{
> +	struct device_node *np;
> +
> +	np = of_find_compatible_node(NULL, NULL, "nintendo,flipper-pic");
> +	BUG_ON(!np);
> +
> +	flipper_irq_host = flipper_pic_init(np);
> +	BUG_ON(!flipper_irq_host);
> +
> +	irq_set_default_host(flipper_irq_host);
> +
> +	of_node_put(np);
> +}
> +
> +/*
> + * Misc functions related to the flipper chipset.
> + *
> + */
> +
> +/**
> + * flipper_quiesce() - quiesce flipper irq controller
> + *
> + * Mask and ack all interrupt sources.
> + *
> + */
> +void flipper_quiesce(void)
> +{
> +	void __iomem *io_base = flipper_irq_host->host_data;
> +
> +	__flipper_quiesce(io_base);
> +}
> +
> +/*
> + * Resets the platform.
> + */
> +void flipper_platform_reset(void)
> +{
> +	void __iomem *io_base;
> +
> +	if (flipper_irq_host && flipper_irq_host->host_data) {
> +		io_base = flipper_irq_host->host_data;
> +		out_8(io_base + FLIPPER_RESET, 0x00);
> +	}
> +}
> +
> +/*
> + * Returns non-zero if the reset button is pressed.
> + */
> +int flipper_is_reset_button_pressed(void)
> +{
> +	void __iomem *io_base;
> +	u32 icr;
> +
> +	if (flipper_irq_host && flipper_irq_host->host_data) {
> +		io_base = flipper_irq_host->host_data;
> +		icr = in_be32(io_base + FLIPPER_ICR);
> +		return !(icr & FLIPPER_ICR_RSS);
> +	}
> +	return 0;
> +}
> +
> diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.h b/ 
> arch/powerpc/platforms/embedded6xx/flipper-pic.h
> new file mode 100644
> index 0000000..e339186
> --- /dev/null
> +++ b/arch/powerpc/platforms/embedded6xx/flipper-pic.h
> @@ -0,0 +1,25 @@
> +/*
> + * arch/powerpc/platforms/embedded6xx/flipper-pic.h
> + *
> + * Nintendo GameCube/Wii "Flipper" interrupt controller support.
> + * Copyright (C) 2004-2009 The GameCube Linux Team
> + * Copyright (C) 2007,2008,2009 Albert Herranz
> + *
> + * 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.
> + *
> + */
> +
> +#ifndef __FLIPPER_PIC_H
> +#define __FLIPPER_PIC_H
> +
> +unsigned int flipper_pic_get_irq(void);
> +void __init flipper_pic_probe(void);
> +
> +void flipper_quiesce(void);
> +void flipper_platform_reset(void);
> +int flipper_is_reset_button_pressed(void);
> +
> +#endif
> -- 
> 1.6.3.3
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH 0/8 userland!] systemtap: Add initial support for ppc32
From: Jim Keniston @ 2009-12-01 19:13 UTC (permalink / raw)
  To: avorontsov, ananth; +Cc: linuxppc-dev, systemtap
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

On Sat, 2009-11-28 at 01:32 +0300, Anton Vorontsov wrote:
> Hi all,
> 
> Here are some patches that add systemtap support for ppc32 machines.
> 
> This is all pretty straightforward, though I didn't test it much,
> only run few 'hello world' taps and decided that it's good enough. ;-)
> 
> I plan to test it more thoughtfully sometime next week, and fix missing
> things (if any). But so far I'm interested in the feedback on this
> initial support.
> 
> Thanks!
> 
> p.s. I though it would be a good idea to cc linuxppc-dev. At least
> kexec-tools guys tend to do it as well.

I think one thing that got missed was completing the support for ppc32
in tapset/powerpc/registers.stp (functions *_arg and [u_]register).  A
lot of the 32-bit code is already in place, having been copied over from
the x86_64 version, but the _reg_offsets[] array and
_stp_get_register_by_offset() work only for 64-bit contexts.  A comment
at the end of _stp_register_regs() suggests that you can get the correct
32-bit offsets by dividing the 64-bit offsets by 2; compare pt_regs
structs to verify.

I'm cc-ing Ananth, who did the original ppc64 work on this file.

The *_arg and [u_]register functions are described in the stapfuncs man
page (but not in the Language Reference doc).
testsuite/systemtap.context/num_args.tcl tests some of these functions
(or used to, at least).

Jim Keniston

^ permalink raw reply

* Re: [RFC PATCH v2 09/11] powerpc: gamecube/wii: flipper interrupt controller support
From: Albert Herranz @ 2009-12-01 19:48 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev
In-Reply-To: <A6D0F7F3-74DB-42BE-BC1D-4C251A75CB16@kernel.crashing.org>

Segher Boessenkool wrote:
>> Add support for the interrupt controller included in the "Flipper"
>> chipset of the Nintendo GameCube video game console.
>> The same interrupt controller is also present in the "Hollywood" chipset
>> of the Nintendo Wii.
>>
>> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
> Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
> 
>> ---
>> v1 -> v2
>> - Build always Flipper interrupt controller when GAMECUBE_COMMON and
>>   get rid of FLIPPER_PIC option. Suggestion by Grant Likely.
>> - Use NO_IRQ instead of -1. Suggestion by Benjamin Herrenschmidt.
>> - Write 0xffffffff instead of ~0 to clear interrupts.
>>   Suggestion by Segher Boessenkool.
>> - Use __fls instead of open coded asm. Suggestion by Segher Boessenkool.
>> - Use a write instead of a read/modify/write to ack interrupts.
>>   Suggestion by Segher Boessenkool and Benjamin Herrenschmidt.
>> - Use name instead of typename for struct irq_chip.
>> - Adapt to updated device tree.
>>
>>  arch/powerpc/platforms/embedded6xx/Makefile      |    1 +
>>  arch/powerpc/platforms/embedded6xx/flipper-pic.c |  263
>> ++++++++++++++++++++++
>>  arch/powerpc/platforms/embedded6xx/flipper-pic.h |   25 ++
>>  3 files changed, 289 insertions(+), 0 deletions(-)
>>  create mode 100644 arch/powerpc/platforms/embedded6xx/flipper-pic.c
>>  create mode 100644 arch/powerpc/platforms/embedded6xx/flipper-pic.h
>>
>> diff --git a/arch/powerpc/platforms/embedded6xx/Makefile
>> b/arch/powerpc/platforms/embedded6xx/Makefile
>> index 0ab7492..b80f47c 100644
>> --- a/arch/powerpc/platforms/embedded6xx/Makefile
>> +++ b/arch/powerpc/platforms/embedded6xx/Makefile
>> @@ -8,3 +8,4 @@ obj-$(CONFIG_PPC_HOLLY)        += holly.o
>>  obj-$(CONFIG_PPC_PRPMC2800)    += prpmc2800.o
>>  obj-$(CONFIG_PPC_C2K)        += c2k.o
>>  obj-$(CONFIG_USBGECKO_UDBG)    += usbgecko_udbg.o
>> +obj-$(CONFIG_GAMECUBE_COMMON)    += flipper-pic.o
>> diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.c
>> b/arch/powerpc/platforms/embedded6xx/flipper-pic.c
>> new file mode 100644
>> index 0000000..d596328
>> --- /dev/null
>> +++ b/arch/powerpc/platforms/embedded6xx/flipper-pic.c
>> @@ -0,0 +1,263 @@
>> +/*
>> + * arch/powerpc/platforms/embedded6xx/flipper-pic.c
>> + *
>> + * Nintendo GameCube/Wii "Flipper" interrupt controller support.
>> + * Copyright (C) 2004-2009 The GameCube Linux Team
>> + * Copyright (C) 2007,2008,2009 Albert Herranz
>> + *
>> + * 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.
>> + *
>> + */
>> +#define DRV_MODULE_NAME "flipper-pic"
>> +#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/irq.h>
>> +#include <linux/of.h>
>> +#include <asm/io.h>
>> +
>> +#include "flipper-pic.h"
>> +
>> +#define FLIPPER_NR_IRQS        32
>> +
>> +/*
>> + * Each interrupt has a corresponding bit in both
>> + * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
>> + *
>> + * Enabling/disabling an interrupt line involves setting/clearing
>> + * the corresponding bit in IMR.
>> + * Except for the RSW interrupt, all interrupts get deasserted
>> automatically
>> + * when the source deasserts the interrupt.
>> + */
>> +#define FLIPPER_ICR        0x00
>> +#define FLIPPER_ICR_RSS        (1<<16) /* reset switch state */
>> +
>> +#define FLIPPER_IMR        0x04
>> +
>> +#define FLIPPER_RESET        0x24
>> +
>> +
>> +/*
>> + * IRQ chip hooks.
>> + *
>> + */
>> +
>> +static void flipper_pic_mask_and_ack(unsigned int virq)
>> +{
>> +    int irq = virq_to_hw(virq);
>> +    void __iomem *io_base = get_irq_chip_data(virq);
>> +    u32 mask = 1 << irq;
>> +
>> +    clrbits32(io_base + FLIPPER_IMR, mask);
>> +    /* this is at least needed for RSW */
>> +    out_be32(io_base + FLIPPER_ICR, mask);
>> +}
>> +
>> +static void flipper_pic_ack(unsigned int virq)
>> +{
>> +    int irq = virq_to_hw(virq);
>> +    void __iomem *io_base = get_irq_chip_data(virq);
>> +
>> +    /* this is at least needed for RSW */
>> +    out_be32(io_base + FLIPPER_ICR, 1 << irq);
>> +}
>> +
>> +static void flipper_pic_mask(unsigned int virq)
>> +{
>> +    int irq = virq_to_hw(virq);
>> +    void __iomem *io_base = get_irq_chip_data(virq);
>> +
>> +    clrbits32(io_base + FLIPPER_IMR, 1 << irq);
>> +}
>> +
>> +static void flipper_pic_unmask(unsigned int virq)
>> +{
>> +    int irq = virq_to_hw(virq);
>> +    void __iomem *io_base = get_irq_chip_data(virq);
>> +
>> +    setbits32(io_base + FLIPPER_IMR, 1 << irq);
>> +}
>> +
>> +
>> +static struct irq_chip flipper_pic = {
>> +    .name        = "flipper-pic",
>> +    .ack        = flipper_pic_ack,
>> +    .mask_ack    = flipper_pic_mask_and_ack,
>> +    .mask        = flipper_pic_mask,
>> +    .unmask        = flipper_pic_unmask,
>> +};
>> +
>> +/*
>> + * IRQ host hooks.
>> + *
>> + */
>> +
>> +static struct irq_host *flipper_irq_host;
>> +
>> +static int flipper_pic_map(struct irq_host *h, unsigned int virq,
>> +               irq_hw_number_t hwirq)
>> +{
>> +    set_irq_chip_data(virq, h->host_data);
>> +    get_irq_desc(virq)->status |= IRQ_LEVEL;
>> +    set_irq_chip_and_handler(virq, &flipper_pic, handle_level_irq);
>> +    return 0;
>> +}
>> +
>> +static void flipper_pic_unmap(struct irq_host *h, unsigned int irq)
>> +{
>> +    set_irq_chip_data(irq, NULL);
>> +    set_irq_chip(irq, NULL);
>> +}
>> +
>> +static int flipper_pic_match(struct irq_host *h, struct device_node *np)
>> +{
>> +    return 1;
>> +}
>> +
>> +
>> +static struct irq_host_ops flipper_irq_host_ops = {
>> +    .map = flipper_pic_map,
>> +    .unmap = flipper_pic_unmap,
>> +    .match = flipper_pic_match,
>> +};
>> +
>> +/*
>> + * Platform hooks.
>> + *
>> + */
>> +
>> +static void __flipper_quiesce(void __iomem *io_base)
>> +{
>> +    /* mask and ack all IRQs */
>> +    out_be32(io_base + FLIPPER_IMR, 0x00000000);
>> +    out_be32(io_base + FLIPPER_ICR, 0xffffffff);
>> +}
>> +
>> +struct irq_host * __init flipper_pic_init(struct device_node *np)
>> +{
>> +    struct device_node *pi;
>> +    struct irq_host *irq_host = NULL;
>> +    struct resource res;
>> +    void __iomem *io_base;
>> +    int retval;
>> +
>> +    pi = of_get_parent(np);
>> +    if (!pi) {
>> +        pr_err("no parent found\n");
>> +        goto out;
>> +    }
>> +    if (!of_device_is_compatible(pi, "nintendo,flipper-pi")) {
>> +        pr_err("unexpected parent compatible\n");
>> +        goto out;
>> +    }
>> +
>> +    retval = of_address_to_resource(pi, 0, &res);
>> +    if (retval) {
>> +        pr_err("no io memory range found\n");
>> +        goto out;
>> +    }
>> +    io_base = ioremap(res.start, resource_size(&res));
>> +
>> +    pr_info("controller at 0x%08x mapped to 0x%p\n", res.start,
>> io_base);
>> +
>> +    __flipper_quiesce(io_base);
>> +
>> +    irq_host = irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, FLIPPER_NR_IRQS,
>> +                  &flipper_irq_host_ops, -1);

This -1 should be NO_IRQ too.
I'll fix this in the next version.

>> +    if (!irq_host) {
>> +        pr_err("failed to allocate irq_host\n");
>> +        return NULL;
>> +    }
>> +
>> +    irq_host->host_data = io_base;
>> +
>> +out:
>> +    return irq_host;
>> +}
>> +
>> +unsigned int flipper_pic_get_irq(void)
>> +{
>> +    void __iomem *io_base = flipper_irq_host->host_data;
>> +    int irq;
>> +    u32 irq_status;
>> +
>> +    irq_status = in_be32(io_base + FLIPPER_ICR) &
>> +             in_be32(io_base + FLIPPER_IMR);
>> +    if (irq_status == 0)
>> +        return NO_IRQ;    /* no more IRQs pending */
>> +
>> +    irq = __ffs(irq_status);
>> +    return irq_linear_revmap(flipper_irq_host, irq);
>> +}
>> +
>> +/*
>> + * Probe function.
>> + *
>> + */
>> +
>> +void __init flipper_pic_probe(void)
>> +{
>> +    struct device_node *np;
>> +
>> +    np = of_find_compatible_node(NULL, NULL, "nintendo,flipper-pic");
>> +    BUG_ON(!np);
>> +
>> +    flipper_irq_host = flipper_pic_init(np);
>> +    BUG_ON(!flipper_irq_host);
>> +
>> +    irq_set_default_host(flipper_irq_host);
>> +
>> +    of_node_put(np);
>> +}
>> +
>> +/*
>> + * Misc functions related to the flipper chipset.
>> + *
>> + */
>> +
>> +/**
>> + * flipper_quiesce() - quiesce flipper irq controller
>> + *
>> + * Mask and ack all interrupt sources.
>> + *
>> + */
>> +void flipper_quiesce(void)
>> +{
>> +    void __iomem *io_base = flipper_irq_host->host_data;
>> +
>> +    __flipper_quiesce(io_base);
>> +}
>> +
>> +/*
>> + * Resets the platform.
>> + */
>> +void flipper_platform_reset(void)
>> +{
>> +    void __iomem *io_base;
>> +
>> +    if (flipper_irq_host && flipper_irq_host->host_data) {
>> +        io_base = flipper_irq_host->host_data;
>> +        out_8(io_base + FLIPPER_RESET, 0x00);
>> +    }
>> +}
>> +
>> +/*
>> + * Returns non-zero if the reset button is pressed.
>> + */
>> +int flipper_is_reset_button_pressed(void)
>> +{
>> +    void __iomem *io_base;
>> +    u32 icr;
>> +
>> +    if (flipper_irq_host && flipper_irq_host->host_data) {
>> +        io_base = flipper_irq_host->host_data;
>> +        icr = in_be32(io_base + FLIPPER_ICR);
>> +        return !(icr & FLIPPER_ICR_RSS);
>> +    }
>> +    return 0;
>> +}
>> +
>> diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.h
>> b/arch/powerpc/platforms/embedded6xx/flipper-pic.h
>> new file mode 100644
>> index 0000000..e339186
>> --- /dev/null
>> +++ b/arch/powerpc/platforms/embedded6xx/flipper-pic.h
>> @@ -0,0 +1,25 @@
>> +/*
>> + * arch/powerpc/platforms/embedded6xx/flipper-pic.h
>> + *
>> + * Nintendo GameCube/Wii "Flipper" interrupt controller support.
>> + * Copyright (C) 2004-2009 The GameCube Linux Team
>> + * Copyright (C) 2007,2008,2009 Albert Herranz
>> + *
>> + * 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.
>> + *
>> + */
>> +
>> +#ifndef __FLIPPER_PIC_H
>> +#define __FLIPPER_PIC_H
>> +
>> +unsigned int flipper_pic_get_irq(void);
>> +void __init flipper_pic_probe(void);
>> +
>> +void flipper_quiesce(void);
>> +void flipper_platform_reset(void);
>> +int flipper_is_reset_button_pressed(void);
>> +
>> +#endif

Cheers,
Albert

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Andreas Schwab @ 2009-12-01 20:43 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: tj, linux-ide, linuxppc-dev, jeff
In-Reply-To: <20091201070834.6A840B7B63@ozlabs.org>

Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:

> This is a libata driver for the "macio" IDE controller used on most Apple
> PowerMac and PowerBooks. It's a libata equivalent of drivers/ide/ppc/pmac.c

Tried it on my iBook G4 and I got an oops during probing, in
pata_macio_common_init+0x378/0x614.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply

* [PATCH 1/3] show_interrupts: use irq_chip::name if available
From: Peter Korsgaard @ 2009-12-01 20:48 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt

struct irq_chip::typename is going away (replaced by name). Use name if
set instead of typename in show_interrupt to make ease transition.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/kernel/irq.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index e5d1211..33e1130 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -203,7 +203,8 @@ int show_interrupts(struct seq_file *p, void *v)
 		seq_printf(p, "%10u ", kstat_irqs(i));
 #endif /* CONFIG_SMP */
 		if (desc->chip)
-			seq_printf(p, " %s ", desc->chip->typename);
+			seq_printf(p, " %s ", desc->chip->name ?
+				   desc->chip->name : desc->chip->typename);
 		else
 			seq_puts(p, "  None      ");
 		seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
-- 
1.6.5

^ permalink raw reply related

* [PATCH 2/3] asm/gpio.h: support gpio_to_irq()
From: Peter Korsgaard @ 2009-12-01 20:48 UTC (permalink / raw)
  To: linuxppc-dev, Anton Vorontsov
In-Reply-To: <1259700494-17869-1-git-send-email-jacmet@sunsite.dk>

gpiolib returns -ENXIO if struct gpio_chip::to_irq isn't set, so it's
safe to always call.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/include/asm/gpio.h |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
index ea04632..38762ed 100644
--- a/arch/powerpc/include/asm/gpio.h
+++ b/arch/powerpc/include/asm/gpio.h
@@ -38,12 +38,9 @@ static inline int gpio_cansleep(unsigned int gpio)
 	return __gpio_cansleep(gpio);
 }
 
-/*
- * Not implemented, yet.
- */
 static inline int gpio_to_irq(unsigned int gpio)
 {
-	return -ENOSYS;
+	return __gpio_to_irq(gpio);
 }
 
 static inline int irq_to_gpio(unsigned int irq)
-- 
1.6.5

^ permalink raw reply related

* [PATCH 3/3] mpc8xxx_gpio: add interrupt support
From: Peter Korsgaard @ 2009-12-01 20:48 UTC (permalink / raw)
  To: linuxppc-dev, Anton Vorontsov, Kumar Gala
In-Reply-To: <1259700494-17869-2-git-send-email-jacmet@sunsite.dk>

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/sysdev/mpc8xxx_gpio.c |  147 ++++++++++++++++++++++++++++++++++++
 1 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c
index 103eace..b46f28b 100644
--- a/arch/powerpc/sysdev/mpc8xxx_gpio.c
+++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
+#include <linux/irq.h>
 
 #define MPC8XXX_GPIO_PINS	32
 
@@ -34,6 +35,7 @@ struct mpc8xxx_gpio_chip {
 	 * open drain mode safely
 	 */
 	u32 data;
+	struct irq_host *irq;
 };
 
 static inline u32 mpc8xxx_gpio2mask(unsigned int gpio)
@@ -111,12 +113,136 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val
 	return 0;
 }
 
+static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
+{
+	struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
+
+	if (mpc8xxx_gc->irq && offset < MPC8XXX_GPIO_PINS)
+		return irq_create_mapping(mpc8xxx_gc->irq, offset);
+	else
+		return -ENXIO;
+}
+
+static void mpc8xxx_gpio_irq_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_desc_data(desc);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned int mask;
+
+	mask = in_be32(mm->regs + GPIO_IER) & in_be32(mm->regs + GPIO_IMR);
+	if (mask)
+		generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
+						     32 - ffs(mask)));
+}
+
+static void mpc8xxx_irq_unmask(unsigned int virq)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned long flags;
+
+	spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+
+	setbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(virq_to_hw(virq)));
+
+	spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+}
+
+static void mpc8xxx_irq_mask(unsigned int virq)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned long flags;
+
+	spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+
+	clrbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(virq_to_hw(virq)));
+
+	spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+}
+
+static void mpc8xxx_irq_ack(unsigned int virq)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+
+	out_be32(mm->regs + GPIO_IER, mpc8xxx_gpio2mask(virq_to_hw(virq)));
+}
+
+static int mpc8xxx_irq_set_type(unsigned int virq, unsigned int flow_type)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned long flags;
+
+	switch (flow_type) {
+	case IRQ_TYPE_EDGE_FALLING:
+		spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+		setbits32(mm->regs + GPIO_ICR,
+			  mpc8xxx_gpio2mask(virq_to_hw(virq)));
+		spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+		break;
+
+	case IRQ_TYPE_EDGE_BOTH:
+		spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+		clrbits32(mm->regs + GPIO_ICR,
+			  mpc8xxx_gpio2mask(virq_to_hw(virq)));
+		spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static struct irq_chip mpc8xxx_irq_chip = {
+	.name		= "mpc8xxx-gpio",
+	.unmask		= mpc8xxx_irq_unmask,
+	.mask		= mpc8xxx_irq_mask,
+	.ack		= mpc8xxx_irq_ack,
+	.set_type	= mpc8xxx_irq_set_type,
+};
+
+static int mpc8xxx_gpio_irq_map(struct irq_host *h, unsigned int virq,
+				irq_hw_number_t hw)
+{
+	set_irq_chip_data(virq, h->host_data);
+	set_irq_chip_and_handler(virq, &mpc8xxx_irq_chip, handle_level_irq);
+	set_irq_type(virq, IRQ_TYPE_NONE);
+
+	return 0;
+}
+
+static int mpc8xxx_gpio_irq_xlate(struct irq_host *h, struct device_node *ct,
+				  u32 *intspec, unsigned int intsize,
+				  irq_hw_number_t *out_hwirq,
+				  unsigned int *out_flags)
+
+{
+	/* interrupt sense values coming from the device tree equal either
+	 * EDGE_FALLING or EDGE_BOTH
+	 */
+	*out_hwirq = intspec[0];
+	*out_flags = intspec[1];
+
+	return 0;
+}
+
+static struct irq_host_ops mpc8xxx_gpio_irq_ops = {
+	.map	= mpc8xxx_gpio_irq_map,
+	.xlate	= mpc8xxx_gpio_irq_xlate,
+};
+
 static void __init mpc8xxx_add_controller(struct device_node *np)
 {
 	struct mpc8xxx_gpio_chip *mpc8xxx_gc;
 	struct of_mm_gpio_chip *mm_gc;
 	struct of_gpio_chip *of_gc;
 	struct gpio_chip *gc;
+	unsigned hwirq;
 	int ret;
 
 	mpc8xxx_gc = kzalloc(sizeof(*mpc8xxx_gc), GFP_KERNEL);
@@ -138,11 +264,32 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
 	gc->direction_output = mpc8xxx_gpio_dir_out;
 	gc->get = mpc8xxx_gpio_get;
 	gc->set = mpc8xxx_gpio_set;
+	gc->to_irq = mpc8xxx_gpio_to_irq;
 
 	ret = of_mm_gpiochip_add(np, mm_gc);
 	if (ret)
 		goto err;
 
+	hwirq = irq_of_parse_and_map(np, 0);
+	if (hwirq == NO_IRQ)
+		goto skip_irq;
+
+	mpc8xxx_gc->irq =
+		irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, MPC8XXX_GPIO_PINS,
+			       &mpc8xxx_gpio_irq_ops, MPC8XXX_GPIO_PINS);
+	if (!mpc8xxx_gc->irq)
+		goto skip_irq;
+
+	mpc8xxx_gc->irq->host_data = mpc8xxx_gc;
+
+	/* ack and mask all irqs */
+	out_be32(mm_gc->regs + GPIO_IER, 0xffffffff);
+	out_be32(mm_gc->regs + GPIO_IMR, 0);
+
+	set_irq_data(hwirq, mpc8xxx_gc);
+	set_irq_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade);
+
+skip_irq:
 	return;
 
 err:
-- 
1.6.5

^ permalink raw reply related

* Re: [PATCH] ppc64: re-enable kexec to allow module loads with CONFIG_MODVERSIONS and CONFIG_RELOCATABLE turned on
From: Neil Horman @ 2009-12-01 21:40 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, nhorman
In-Reply-To: <20091119195216.GC11414@hmsreliant.think-freely.org>

>> Paul, Ben, given that Rusty hasn't come back with any opinion on this patch,
>do you
>> feel comfortable merging it via the ppc tree?  Currently the earlyinit routine
>> is only compiled in and used for your arch, so I think its fairly benign.
>
>Sorry, I *did* track down the archives for linuxppc-dev, then find your post,
>then read your patch.  But I didn't actually reply.
>
>Other than minor issues, there's one significant one: you shouldn't be trying
>to change rodata.  It might work on PPC today, but it's poor form at least.
>
>How's this?  Untested on ppc.
>
I'll try grab a ppc64 system and test this soon.

>Other changes:
>1) I also changed reloc_start to an array; this is a good idea for any
>   linker-defined symbols so the compiler can't make assumptions about size.
Ok, I'll certainly trust your linker skill over mine :)

>2) local.h?  How about module.h?
Seems good to me
>3) I don't think the extra ". = 0" is necessary.
Its not, I was just trying to be clear about where reloc_start was to be placed.

>4) ARCH_USES_RELOC_ENTRIES isn't clear enough for me; I prefer
>   ARCH_RELOCATE_KCRCTAB.
Sounds good to me.


I'll test this as soon as I'm able
Thanks!
Neil

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Benjamin Herrenschmidt @ 2009-12-01 22:34 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: tj, linux-ide, linuxppc-dev, jeff
In-Reply-To: <m2hbsazapo.fsf@igel.home>

On Tue, 2009-12-01 at 21:43 +0100, Andreas Schwab wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
> 
> > This is a libata driver for the "macio" IDE controller used on most Apple
> > PowerMac and PowerBooks. It's a libata equivalent of drivers/ide/ppc/pmac.c
> 
> Tried it on my iBook G4 and I got an oops during probing, in
> pata_macio_common_init+0x378/0x614.

Any chance you can send me the oops log ? (you have a digital
camera ? :-)

What model of ibook ? There's one here I could try on I think but it
might not be the same model.

Cheers,
Ben.

^ permalink raw reply

* EP440XS board boot problem(Note:similart to Sequoia)
From: Allan Wang @ 2009-12-01 22:38 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]

I resend my message since my last message has wrong coding.


I am new to the list. I am still newbie to embedded linux. I have bought an ep440xs board which is similar to sequoia board. u-boot is working. I am trying to make it run linux.  I have the following problems and need your help. Thank you very much:


I am using linux kernel 2.6.30.4. I encounter 2 problems:
1. After console_init() is called inside start_kernel(), the console starts printing garbage like:
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
serial8250.0: ttyS0 at MMIO 0x1ef600300 (irq = 16) is a 16550A
������������������������������
����������������������������
���������������������������������
������������������������������
�����������������.
2. It pakics when mounting the root file system(NFS):
(gdb) bt
#0  panic (fmt=0xc0290e94 "VFS: Unable to mount root fs on %s")
at kernel/panic.c:70
#1  0xc02d8ce0 in mount_block_root (name=0xc0290de4 "/dev/root", flags=0x8001)
at init/do_mounts.c:272
#2  0xc02d9084 in prepare_namespace () at init/do_mounts.c:415
#3  0xc02d81ec in kernel_init (unused=<value optimized out>) at init/main.c:885
#4  0xc000de60 in kernel_thread ()
There is a patch for Sequoia board to delete /chosen part in sequoia.dts, is /chosen required?

Allan



      

[-- Attachment #2: Type: text/html, Size: 2096 bytes --]

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Benjamin Herrenschmidt @ 2009-12-01 22:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: tj, linux-ide, linuxppc-dev, jeff
In-Reply-To: <m2hbsazapo.fsf@igel.home>

On Tue, 2009-12-01 at 21:43 +0100, Andreas Schwab wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
> 
> > This is a libata driver for the "macio" IDE controller used on most Apple
> > PowerMac and PowerBooks. It's a libata equivalent of drivers/ide/ppc/pmac.c
> 
> Tried it on my iBook G4 and I got an oops during probing, in
> pata_macio_common_init+0x378/0x614.

Bah, I know what it is ... a last minute cleanup that breaks the PCI
variants of the cell. I'll send a new patch later today along with
other fixes.

Cheers,
Ben.

^ permalink raw reply

* Re: EP440XS board boot problem(Note:similart to Sequoia)
From: Wolfgang Denk @ 2009-12-01 23:10 UTC (permalink / raw)
  To: Allan Wang; +Cc: linuxppc-dev
In-Reply-To: <401793.31718.qm@web52903.mail.re2.yahoo.com>

Dear Allan Wang,

In message <401793.31718.qm@web52903.mail.re2.yahoo.com> you wrote:
>
> I am new to the list. I am still newbie to embedded linux. I have
> bought an ep440xs board which is similar to sequoia board. u-boot is
> working. I am trying to make it run linux. I have the following
> problems and need your help. Thank you very much:

Which exact version of U-Boot are you running on this board?

I guess this is a out-of-tree port, i. e. not part of the mainline
U-Boot repository - so are you sure that device tree support is
enabled in your version of U-Boot?
> 
> I am using linux kernel 2.6.30.4. I encounter 2 problems:
> 1. After console_init() is called inside start_kernel(), the console starts printing garbage like:
> Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
> serial8250.0: ttyS0 at MMIO 0x1ef600300 (irq = 16) is a 16550A
> ������������������������������
...

What is your exact boot command?

Which boot arguments do you pass to the kernel?

What is ytour console baud rate in U-Boot, and what sort of "console="
boot argument do you pass to the Linux kernel?

What does your device tree look like?


> 2. It pakics when mounting the root file system(NFS):
> (gdb) bt
> #0 panic (fmt=0xc0290e94 "VFS: Unable to mount root fs on %s")

So what is the "%s" argument here? Which sort of root file system are
you trying to mount - NFS, ramdisk, UBIFS, ... ?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
"He only drinks when he gets depressed." "Why does he get depressed?"
"Sometimes it's because he hasn't had a drink."
                                     - Terry Pratchett, _Men at Arms_

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Benjamin Herrenschmidt @ 2009-12-01 23:19 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, Holger Macht, linuxppc-dev, Jeff Garzik
In-Reply-To: <4B14CD22.4020806@kernel.org>

On Tue, 2009-12-01 at 17:00 +0900, Tejun Heo wrote:

> > +#define IDE_WAKEUP_DELAY	(1*HZ)
> 
> nitpick: In libata, it's common to use msecs for timing values so that
> might be a better option.

Yeah, that's cruft lifted from the old driver, I'll fix it.

> > +static const struct pata_macio_timing *pata_macio_find_timing(
> > +					    struct pata_macio_priv *priv,
> > +					    int mode)
> > +{
> > +	int i = 0;
> > +
> > +	while (priv->timings[i].mode > 0) {
> > +		if (priv->timings[i].mode == mode)
> > +			return &priv->timings[i];
> > +		i++;
> > +	}
> > +	return NULL;
> 
> Wouldn't for (i = 0; ...) look better?

Yeah, I suppose so :-)

> > +static void pata_macio_bmdma_start(struct ata_queued_cmd *qc)
> > +{
> > +	struct ata_port *ap = qc->ap;
> > +	struct pata_macio_priv *priv = ap->private_data;
> > +	struct dbdma_regs __iomem *dma_regs = ap->ioaddr.bmdma_addr;
> > +
> > +	dev_dbgdma(priv->dev, "%s: qc %p\n", __func__, qc);
> > +
> > +	writel((RUN << 16) | RUN, &dma_regs->control);
> > +	/* Make sure it gets to the controller right now */
> > +	(void)readl(&dma_regs->control);
> 
> Is flushing necessary here?  There's no ordering issue here, right?

That's also lifted pretty-much as-is from the old driver. Now I probably
wrote that part of the old driver too ages ago :-) I think I just want
to make sure the DMA starts asap and doesn't sit in some bridge write
posting queue for hundreds of cycles.

> > +static void pata_macio_bmdma_stop(struct ata_queued_cmd *qc)
> > +{
> > +	struct ata_port *ap = qc->ap;
> > +	struct pata_macio_priv *priv = ap->private_data;
> > +	struct dbdma_regs __iomem *dma_regs = ap->ioaddr.bmdma_addr;
> > +
> > +	dev_dbgdma(priv->dev, "%s: qc %p\n", __func__, qc);
> > +
> > +	/* Stop the DMA engine and wait for it to full halt */
> > +	writel (((RUN|WAKE|DEAD) << 16), &dma_regs->control);
> > +	while (readl(&dma_regs->status) & RUN)
> > +		udelay(1);
> 
> Heh... this is a scary looking loop.  It would be great if the above
> loop can be capped somehow.

Yeah, again, lifted from the old driver. We do that sort of loops in
various other drivers that use those DBDMA channels and I don't think
ever saw the loop hang, so at least those HW aren't -that- broken but I
suppose a little timeout wouldn't hurt. Not sure what to do if we hit it
tho.
 
> > +static u8 pata_macio_bmdma_status(struct ata_port *ap)
> > +{
> > +	struct pata_macio_priv *priv = ap->private_data;
> > +	struct dbdma_regs __iomem *dma_regs = ap->ioaddr.bmdma_addr;
> > +	u32 dstat, rstat = ATA_DMA_INTR;
> > +	unsigned long timeout = 0;
> > +
> > +	dstat = readl(&dma_regs->status);
> > +
> > +	dev_dbgdma(priv->dev, "%s: dstat=%x\n", __func__, dstat);
> > +
> > +	/* We have to things to deal with here:
>                    ^^
>                    two

Yup.

> > +/* port_start is when we allocate the DMA command list */
> > +static int pata_macio_port_start(struct ata_port *ap)
> > +{
> > +	struct pata_macio_priv *priv = ap->private_data;
> > +	struct dbdma_regs __iomem *dma_regs = ap->ioaddr.bmdma_addr;
> > +
> > +	if (dma_regs == NULL)
> > +		return 0;
> > +
> > +	/* Make sure DMA controller is stopped */
> > +	writel((RUN|PAUSE|FLUSH|WAKE|DEAD) << 16, &dma_regs->control);
> > +	while (readl(&dma_regs->status) & RUN)
> > +		udelay(1);
> 
> Hmmm.... this probably belongs to ->freeze() which is responsible for
> stopping any in-flight operations and masking IRQ and libata will call
> it during initialization before requesting IRQ, so you won't need to
> call it explicitly here.

Well, I'm not sure I really -need- the above thing. It's there mostly
for the sake of paranoia. I suppose in case the firmware left it in some
stange state. Anyway, will move to freeze.

> > +#ifdef CONFIG_PMAC_MEDIABAY
> > +static void pata_macio_mb_event(struct macio_dev* mdev, int mb_state)
> > +{
> > +	struct ata_host *host = macio_get_drvdata(mdev);
> > +	struct ata_port *ap;
> > +	struct ata_eh_info *ehi;
> > +	struct ata_device *dev;
> > +	unsigned long flags;
> > +
> > +	if (!host)
> > +		return;
> > +	ap = host->ports[0];
> > +	spin_lock_irqsave(ap->lock, flags);
> > +	ehi = &ap->link.eh_info;
> > +	if (mb_state == MB_CD) {
> > +		ata_ehi_push_desc(ehi, "mediabay plug");
> > +		ata_ehi_hotplugged(ehi);
> > +		ata_port_freeze(ap);
> > +	} else {
> > +		ata_ehi_push_desc(ehi, "mediabay unplug");
> > +		ata_for_each_dev(dev, &ap->link, ALL)
> > +			dev->flags |= ATA_DFLAG_DETACH;
> > +		ata_port_schedule_eh(ap);
> 
> I think you'll need an ata_port_freeze() or abort() here because at
> this point the drive is already gone and all in-flight commands need
> to be failed right away.  Holger, do you remember why
> ata_acpi_detach_device() is using ata_port_schedule_eh() instead?  Was
> it because ata_port_freeze() might end up poking registers after
> hotunplug happened?  ISTR reports where accessing any register there
> causing the whole system to lock up but then why can't it use
> ata_port_abort() instead?

I'll try. Which one ? freeze or abort tho ?

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Tejun Heo @ 2009-12-01 23:27 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linux-ide, Holger Macht, linuxppc-dev, Jeff Garzik
In-Reply-To: <1259709552.2076.1053.camel@pasglop>

Hello,

On 12/02/2009 08:19 AM, Benjamin Herrenschmidt wrote:
>> I think you'll need an ata_port_freeze() or abort() here because at
>> this point the drive is already gone and all in-flight commands need
>> to be failed right away.  Holger, do you remember why
>> ata_acpi_detach_device() is using ata_port_schedule_eh() instead?  Was
>> it because ata_port_freeze() might end up poking registers after
>> hotunplug happened?  ISTR reports where accessing any register there
>> causing the whole system to lock up but then why can't it use
>> ata_port_abort() instead?
> 
> I'll try. Which one ? freeze or abort tho ?

Conceptually freeze would be more approriate but the side effect is
that the port is frozen and EH will try to thaw it by resetting it.
So, abort would work better.

Thanks.

-- 
tejun

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Benjamin Herrenschmidt @ 2009-12-01 23:35 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, Holger Macht, linuxppc-dev, Jeff Garzik
In-Reply-To: <4B15A67C.2030102@kernel.org>

On Wed, 2009-12-02 at 08:27 +0900, Tejun Heo wrote:
> Conceptually freeze would be more approriate but the side effect is
> that the port is frozen and EH will try to thaw it by resetting it.
> So, abort would work better.

BTW. For a plug event, what should I do ? freeze is fine ? Or just
schedule eh ? Right now, when plugging I see an exception Emask 0x10
etc... message in the log when plugging which isn't totally nice :-)

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Tejun Heo @ 2009-12-01 23:44 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linux-ide, Holger Macht, linuxppc-dev, Jeff Garzik
In-Reply-To: <1259710543.2076.1054.camel@pasglop>

On 12/02/2009 08:35 AM, Benjamin Herrenschmidt wrote:
> On Wed, 2009-12-02 at 08:27 +0900, Tejun Heo wrote:
>> Conceptually freeze would be more approriate but the side effect is
>> that the port is frozen and EH will try to thaw it by resetting it.
>> So, abort would work better.
> 
> BTW. For a plug event, what should I do ? freeze is fine ? Or just
> schedule eh ? Right now, when plugging I see an exception Emask 0x10
> etc... message in the log when plugging which isn't totally nice :-)

freeze() and please don't fight the EH messages from low level driver.
If it's too much, we need to update core layer but given the variety
of phy related bugs, I think we need those messages.

Thanks.

-- 
tejun

^ permalink raw reply

* Re: [PATCH 5/5] libata/drivers: Add pata_macio, driver Apple PowerMac/PowerBook IDE controller
From: Benjamin Herrenschmidt @ 2009-12-02  0:00 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, Holger Macht, linuxppc-dev, Jeff Garzik
In-Reply-To: <4B15AA4F.5040309@kernel.org>

On Wed, 2009-12-02 at 08:44 +0900, Tejun Heo wrote:
> > BTW. For a plug event, what should I do ? freeze is fine ? Or just
> > schedule eh ? Right now, when plugging I see an exception Emask 0x10
> > etc... message in the log when plugging which isn't totally nice :-)
> 
> freeze() and please don't fight the EH messages from low level driver.
> If it's too much, we need to update core layer but given the variety
> of phy related bugs, I think we need those messages.

Eh, ok :-) No biggie.

Cheers,
Ben.

^ permalink raw reply

* Serial console under current qemu is still an issue.
From: Rob Landley @ 2009-12-02  0:13 UTC (permalink / raw)
  To: linuxppc-dev

Last month I reported a serial console problem:
  http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-October/076727.html

And bisected the problem to find the patch to revert that fixed it for me:
  http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-October/077059.html

The bug still hasn't been fixed, but reverting the patch stopped working during 
this developmpent series (because it no longer cleanly reverse applies).

Would anybody like to comment on this?  I can provide a qemu-based test 
environment if you'd like, it's easily reproducible...

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds

^ permalink raw reply

* [PATCH 1/5] powerpc/macio: Add devres support to macio_device
From: Benjamin Herrenschmidt @ 2009-12-02  0:36 UTC (permalink / raw)
  To: linux-ide; +Cc: tj, linuxppc-dev, jeff

This adds some basic devres support. When enabled via macio_enable_devres()
resources requested by drivers will be automatically released.

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

 arch/powerpc/include/asm/macio.h |    2 +
 drivers/macintosh/macio_asic.c   |   47 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

--- linux-work.orig/arch/powerpc/include/asm/macio.h	2009-11-30 12:48:33.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/macio.h	2009-11-30 14:16:55.000000000 +1100
@@ -78,6 +78,8 @@ static inline unsigned long macio_resour
 	return res->end - res->start + 1;
 }
 
+extern int macio_enable_devres(struct macio_dev *dev);
+
 extern int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name);
 extern void macio_release_resource(struct macio_dev *dev, int resource_no);
 extern int macio_request_resources(struct macio_dev *dev, const char *name);
Index: linux-work/drivers/macintosh/macio_asic.c
===================================================================
--- linux-work.orig/drivers/macintosh/macio_asic.c	2009-11-30 12:41:12.000000000 +1100
+++ linux-work/drivers/macintosh/macio_asic.c	2009-11-30 14:17:19.000000000 +1100
@@ -538,6 +538,42 @@ void macio_unregister_driver(struct maci
 	driver_unregister(&drv->driver);
 }
 
+/* Managed MacIO resources */
+struct macio_devres {
+	u32	res_mask;
+};
+
+static void maciom_release(struct device *gendev, void *res)
+{
+	struct macio_dev *dev = to_macio_device(gendev);
+	struct macio_devres *dr = res;
+	int i, max;
+
+	max = min(dev->n_resources, 32);
+	for (i = 0; i < max; i++) {
+		if (dr->res_mask & (1 << i))
+			macio_release_resource(dev, i);
+	}
+}
+
+int macio_enable_devres(struct macio_dev *dev)
+{
+	struct macio_devres *dr;
+
+	dr = devres_find(&dev->ofdev.dev, maciom_release, NULL, NULL);
+	if (!dr) {
+		dr = devres_alloc(maciom_release, sizeof(*dr), GFP_KERNEL);
+		if (!dr)
+			return -ENOMEM;
+	}
+	return devres_get(&dev->ofdev.dev, dr, NULL, NULL) != NULL;
+}
+
+static struct macio_devres * find_macio_dr(struct macio_dev *dev)
+{
+	return devres_find(&dev->ofdev.dev, maciom_release, NULL, NULL);
+}
+
 /**
  *	macio_request_resource - Request an MMIO resource
  * 	@dev: pointer to the device holding the resource
@@ -555,6 +591,8 @@ void macio_unregister_driver(struct maci
 int macio_request_resource(struct macio_dev *dev, int resource_no,
 			   const char *name)
 {
+	struct macio_devres *dr = find_macio_dr(dev);
+
 	if (macio_resource_len(dev, resource_no) == 0)
 		return 0;
 		
@@ -562,6 +600,9 @@ int macio_request_resource(struct macio_
 				macio_resource_len(dev, resource_no),
 				name))
 		goto err_out;
+
+	if (dr && resource_no < 32)
+		dr->res_mask |= 1 << resource_no;
 	
 	return 0;
 
@@ -582,10 +623,14 @@ err_out:
  */
 void macio_release_resource(struct macio_dev *dev, int resource_no)
 {
+	struct macio_devres *dr = find_macio_dr(dev);
+
 	if (macio_resource_len(dev, resource_no) == 0)
 		return;
 	release_mem_region(macio_resource_start(dev, resource_no),
 			   macio_resource_len(dev, resource_no));
+	if (dr && resource_no < 32)
+		dr->res_mask &= ~(1 << resource_no);
 }
 
 /**
@@ -744,3 +789,5 @@ EXPORT_SYMBOL(macio_request_resource);
 EXPORT_SYMBOL(macio_release_resource);
 EXPORT_SYMBOL(macio_request_resources);
 EXPORT_SYMBOL(macio_release_resources);
+EXPORT_SYMBOL(macio_enable_devres);
+

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox