ppc64: prepare for integration of BPA platform
Arnd Bergmann
maintainercover ppc64: prepare for integration of BPA platform
This series of patches adds a bit of infrastructure in preparation of getting the Broadband Processor Architecture (BPA) into the kernel as a new platform type of ppc64.
BPA is currently used in a single machine from IBM, with others likely to be added at a later point.
None of these preparation patches are really specific to the architecture itself. Hopefully, I will be able to send the actual platform code really soon now.
BPA and pSeries can share some code, mostly because they are both using rtas. The first two patches are splitting out the common code from the pSeries_pci implementation into a generic rtas_pci base.
The nvram and watchdog drivers are pretty generic and are first used in the new machine.
Arnd <><
Arnd Bergmann
maintainerPATCH 1/4 ppc64: rename arch/ppc64/kernel/pSeries_pci.c
Rename pSeries_pci.c to rtas_pci.c as a preparation to generalize it for use by BPA. Most of the file can be used by any machine that implements rtas.
arch/ppc64/kernel/Makefile +2 -1
@@ -32,13 +32,14 @@ obj-$(CONFIG_PPC_MULTIPLATFORM) += nvram obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \ pSeries_nvram.o rtasd.o ras.o pSeries_reconfig.o \ - xics.o rtas.o pSeries_setup.o pSeries_iommu.o + xics.o pSeries_setup.o pSeries_iommu.o obj-$(CONFIG_EEH) += eeh.o obj-$(CONFIG_PROC_FS) += proc_ppc64.o obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o +obj-$(CONFIG_PPC_RTAS) += rtas.o rtas_pci.o obj-$(CONFIG_RTAS_PROC) += rtas-proc.o obj-$(CONFIG_SCANLOG) += scanlog.o obj-$(CONFIG_VIOPATH) += viopath.o
arch/ppc64/kernel/pSeries_pci.c +0 -602
602 lines not on this page · raw message
arch/ppc64/kernel/rtas_pci.c +602 -0
602 lines not on this page · raw message
Arnd Bergmann
maintainerPATCH 2/4 ppc64: Split out pSeries specific code from rtas_pci.c
In reply to Arnd BergmannBPA is using rtas for PCI but should not be confused by pSeries code. This also avoids some #ifdefs. Other platforms that want to use rtas_pci.c should also create their own platform_pci.c with platform specific fixups.
arch/ppc64/kernel/mpic.h +3 -0
@@ -265,3 +265,6 @@ extern void mpic_send_ipi(unsigned int iextern int mpic_get_one_irq (struct mpic *mpic,struct pt_regs *regs);/* This one gets to the primary mpic */ extern int mpic_get_irq (struct pt_regs *regs); + +/* global mpic for pSeries */ +extern struct mpic *pSeries_mpic;
arch/ppc64/kernel/pSeries_pci.c +138 -0
138 lines not on this page · raw message
arch/ppc64/kernel/rtas_pci.c +5 -112
151 lines not on this page · raw message
Arnd Bergmann
maintainerPATCH 3/4 ppc64: add a simple nvram lowlevel driver
In reply to Arnd BergmannUnlike pSeries, we don't want to use rtas for accessing nvram because the nvram device is rather large and it already is mapped into the physical address space, which makes a much simpler and faster design possible.
The firmware provides the location and size of the nvram in the device tree, so it does not really contain any hardware specific bits and could be used on other machines as well.
From: Utz Bacher <[email protected]>
arch/ppc64/kernel/bpa_nvram.c new file +118 -0
@@ -0,0 +1,118 @@ +/* +* NVRAM for CPBW +* +* (C) Copyright IBM Corp. 2005 +* +* Authors : Utz Bacher <[email protected]> +* +* 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include <linux/fs.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/spinlock.h> +#include <linux/types.h> + +#include <asm/machdep.h> +#include <asm/nvram.h> +#include <asm/prom.h> + +static void __iomem *bpa_nvram_start; +static long bpa_nvram_len; +static spinlock_t bpa_nvram_lock =SPIN_LOCK_UNLOCKED ; + +static ssize_t bpa_nvram_read (char *buf,size_t count,loff_t *index) +{ +unsigned long flags; + +if (*index >= bpa_nvram_len) +return 0 ; +if (*index + count > bpa_nvram_len) + count = bpa_nvram_len - *index; + +spin_lock_irqsave (&bpa_nvram_lock, flags); + +memcpy_fromio (buf, bpa_nvram_start + *index, count); + +spin_unlock_irqrestore (&bpa_nvram_lock, flags); + + *index += count; +return count; +} + +static ssize_t bpa_nvram_write (char *buf,size_t count,loff_t *index) +{ +unsigned long flags; + +if (*index >= bpa_nvram_len) +return 0 ; +if (*index + count > bpa_nvram_len) + count = bpa_nvram_len - *index; + +spin_lock_irqsave (&bpa_nvram_lock, flags); + +memcpy_toio (bpa_nvram_start + *index, buf, count); + +spin_unlock_irqrestore (&bpa_nvram_lock, flags); + + *index += count; +return count; +} + +static ssize_t bpa_nvram_get_size (void ) +{ +return bpa_nvram_len; +} + +int __init bpa_nvram_init (void ) +{ +struct device_node *nvram_node; +unsigned long *buffer; +int proplen; +unsigned long nvram_addr; +int ret; + + ret = -ENODEV ; + nvram_node =of_find_node_by_type (NULL ,"nvram" ); +if (!nvram_node) + goto out; + + ret = -EIO ; + buffer = (unsigned long *)get_property (nvram_node,"reg" , &proplen); +if (proplen !=2 *sizeof (unsigned long )) + goto out; + + ret = -ENODEV ; + nvram_addr = buffer[0 ]; + bpa_nvram_len = buffer[1 ]; +if ( (!bpa_nvram_len) || (!nvram_addr) ) + goto out; + + bpa_nvram_start =ioremap (nvram_addr, bpa_nvram_len); +if (!bpa_nvram_start) + goto out; + +printk (KERN_INFO "BPA NVRAM, %luk mapped to %p\n" , + bpa_nvram_len >>10 , bpa_nvram_start); + + ppc_md.nvram_read = bpa_nvram_read; + ppc_md.nvram_write = bpa_nvram_write; + ppc_md.nvram_size = bpa_nvram_get_size; + +out: +of_node_put (nvram_node); +return ret; +}
include/asm-ppc64/nvram.h +1 -0
@@ -70,6 +70,7 @@extern int pSeries_nvram_init (void );extern int pmac_nvram_init (void ); +extern int bpa_nvram_init (void );/* PowerMac specific nvram stuffs */
Arnd Bergmann
maintainerPATCH 4/4 ppc64: add an rtas based watchdog driver
In reply to Arnd BergmannAdd a watchdog using the RTAS OS surveillance service. This is provided as a simpler alternative to rtasd. The added value is that it works with standard watchdog client programs and can therefore also do user space monitoring.
On BPA, rtasd is not really useful because the hardware does not have much to report with event-scan.
The driver should also work on other platforms that support the OS surveillance rtas calls.
From: Utz Bacher <[email protected]>
drivers/char/watchdog/Kconfig +10 -0
@@ -414,6 +414,16 @@ config WATCHDOG_RIO machines. The watchdog timeout period is normally one minute but can be changed with a boot-time parameter. +# ppc64 RTAS watchdog +config WATCHDOG_RTAS + tristate "RTAS watchdog" + depends on WATCHDOG && PPC_RTAS + help + This driver adds watchdog support for the RTAS watchdog. + + To compile this driver as a module, choose M here. The module + will be called wdrtas. + # # ISA-based Watchdog Cards #
drivers/char/watchdog/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb. obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o +obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o # Only one watchdog can succeed. We probe the hardware watchdog # drivers first, then the softdog driver. This means if your hardware
drivers/char/watchdog/wdrtas.c +691 -0
691 lines not on this page · raw message
Re: [PATCH 1/4] ppc64: rename arch/ppc64/kernel/pSeries_pci.c
In reply to Arnd Bergmannarch/ppc64/kernel/pSeries_pci.c line 88
Quoted 11 lines · Arnd Bergmann
arch/ppc64/kernel/pSeries_pci.c +0
-10-if (buid) { - ret =rtas_call (ibm_read_pci_config,4 ,2 , &returnval, - addr, buid >>32 , buid &0xffffffff , size); - }else { - ret =rtas_call (read_pci_config,2 ,2 , &returnval, addr, size); - } - *val = returnval; - -if (ret) -return PCIBIOS_DEVICE_NOT_FOUND ;
You might want to be consistent wrt. braces for one-line conditional statements.
Jörn
Signature · 3 lines
Optimizations always bust things, because all optimizations are, in the long haul, a form of cheating, and cheaters eventually get caught. -- Larry Wall
Re: [PATCH 1/4] ppc64: rename arch/ppc64/kernel/pSeries_pci.c
Quoted 2 lines
You might want to be consistent wrt. braces for one-line conditional statements.
Perhaps he is consistent - just not to any of the rules that you considered.
For example, I will add braces even to a one-line conditional if due to wrapping long lines, it really takes two or more screen lines for the conditional.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401Re: [PATCH 1/4] ppc64: rename arch/ppc64/kernel/pSeries_pci.c
In reply to Arnd BergmannQuoted 3 lines · Arnd Bergmann
Rename
pSeries_pci.ctortas_pci.cas a preparation to generalize it for use by BPA. Most of the file can be used by any machine that implements rtas.
Hmmm, you rename pSeries_pci.c to rtas_pci.c and then in the next patch you recreate pSeries_pci.c and move some stuff from rtas_pci.c into it. Could we have one patch that creates rtas_pci.c and just moves stuff from pSeries_pci.c to it?
Paul.
Arnd Bergmann
maintainerRe: [PATCH 1/4] ppc64: rename arch/ppc64/kernel/pSeries_pci.c
Quoted 4 lines · Paul Mackerras
Hmmm, you rename
pSeries_pci.ctortas_pci.cand then in the next patch you recreatepSeries_pci.cand move some stuff fromrtas_pci.cinto it. Could we have one patch that createsrtas_pci.cand just moves stuff frompSeries_pci.cto it?
Sure. I wanted to make it easier to review as the rename patch is trivial and the second patch is less to read than the combined one. In my next update I will fold the two together.
Arnd <><