···11/*22- * PreP compliant NVRAM access33- * This needs to be updated for PPC6422+ * NVRAM definitions and access functions.43 *54 * This program is free software; you can redistribute it and/or65 * modify it under the terms of the GNU General Public License···78 * 2 of the License, or (at your option) any later version.89 */9101010-#ifndef _PPC64_NVRAM_H1111-#define _PPC64_NVRAM_H1111+#ifndef _ASM_POWERPC_NVRAM_H1212+#define _ASM_POWERPC_NVRAM_H12131314#define NVRW_CNT 0x201415#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */···8788extern void pmac_xpram_write(int xpaddr, u8 data);88898990/* Synchronize NVRAM */9090-extern int nvram_sync(void);9191+extern void nvram_sync(void);9292+9393+/* Normal access to NVRAM */9494+extern unsigned char nvram_read_byte(int i);9595+extern void nvram_write_byte(unsigned char c, int i);91969297/* Some offsets in XPRAM */9398#define PMAC_XPRAM_MACHINE_LOC 0xe4···115112 _IOWR('p', 0x40, int)116113117114#define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */115115+#define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */118116119119-#endif /* _PPC64_NVRAM_H */117117+#endif /* _ASM_POWERPC_NVRAM_H */
-220
include/asm-ppc64/prom.h
···11-#ifndef _PPC64_PROM_H22-#define _PPC64_PROM_H33-44-/*55- * Definitions for talking to the Open Firmware PROM on66- * Power Macintosh computers.77- *88- * Copyright (C) 1996 Paul Mackerras.99- *1010- * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.1111- *1212- * This program is free software; you can redistribute it and/or1313- * modify it under the terms of the GNU General Public License1414- * as published by the Free Software Foundation; either version1515- * 2 of the License, or (at your option) any later version.1616- */1717-#include <linux/config.h>1818-#include <linux/proc_fs.h>1919-#include <asm/atomic.h>2020-2121-#define PTRRELOC(x) ((typeof(x))((unsigned long)(x) - offset))2222-#define PTRUNRELOC(x) ((typeof(x))((unsigned long)(x) + offset))2323-#define RELOC(x) (*PTRRELOC(&(x)))2424-2525-/* Definitions used by the flattened device tree */2626-#define OF_DT_HEADER 0xd00dfeed /* marker */2727-#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */2828-#define OF_DT_END_NODE 0x2 /* End node */2929-#define OF_DT_PROP 0x3 /* Property: name off, size,3030- * content */3131-#define OF_DT_NOP 0x4 /* nop */3232-#define OF_DT_END 0x93333-3434-#define OF_DT_VERSION 0x103535-3636-/*3737- * This is what gets passed to the kernel by prom_init or kexec3838- *3939- * The dt struct contains the device tree structure, full pathes and4040- * property contents. The dt strings contain a separate block with just4141- * the strings for the property names, and is fully page aligned and4242- * self contained in a page, so that it can be kept around by the kernel,4343- * each property name appears only once in this page (cheap compression)4444- *4545- * the mem_rsvmap contains a map of reserved ranges of physical memory,4646- * passing it here instead of in the device-tree itself greatly simplifies4747- * the job of everybody. It's just a list of u64 pairs (base/size) that4848- * ends when size is 04949- */5050-struct boot_param_header5151-{5252- u32 magic; /* magic word OF_DT_HEADER */5353- u32 totalsize; /* total size of DT block */5454- u32 off_dt_struct; /* offset to structure */5555- u32 off_dt_strings; /* offset to strings */5656- u32 off_mem_rsvmap; /* offset to memory reserve map */5757- u32 version; /* format version */5858- u32 last_comp_version; /* last compatible version */5959- /* version 2 fields below */6060- u32 boot_cpuid_phys; /* Physical CPU id we're booting on */6161- /* version 3 fields below */6262- u32 dt_strings_size; /* size of the DT strings block */6363-};6464-6565-6666-6767-typedef u32 phandle;6868-typedef u32 ihandle;6969-7070-struct address_range {7171- unsigned long space;7272- unsigned long address;7373- unsigned long size;7474-};7575-7676-struct interrupt_info {7777- int line;7878- int sense; /* +ve/-ve logic, edge or level, etc. */7979-};8080-8181-struct pci_address {8282- u32 a_hi;8383- u32 a_mid;8484- u32 a_lo;8585-};8686-8787-struct isa_address {8888- u32 a_hi;8989- u32 a_lo;9090-};9191-9292-struct isa_range {9393- struct isa_address isa_addr;9494- struct pci_address pci_addr;9595- unsigned int size;9696-};9797-9898-struct reg_property {9999- unsigned long address;100100- unsigned long size;101101-};102102-103103-struct reg_property32 {104104- unsigned int address;105105- unsigned int size;106106-};107107-108108-struct reg_property64 {109109- unsigned long address;110110- unsigned long size;111111-};112112-113113-struct property {114114- char *name;115115- int length;116116- unsigned char *value;117117- struct property *next;118118-};119119-120120-struct device_node {121121- char *name;122122- char *type;123123- phandle node;124124- phandle linux_phandle;125125- int n_addrs;126126- struct address_range *addrs;127127- int n_intrs;128128- struct interrupt_info *intrs;129129- char *full_name;130130-131131- struct property *properties;132132- struct device_node *parent;133133- struct device_node *child;134134- struct device_node *sibling;135135- struct device_node *next; /* next device of same type */136136- struct device_node *allnext; /* next in list of all nodes */137137- struct proc_dir_entry *pde; /* this node's proc directory */138138- struct kref kref;139139- unsigned long _flags;140140- void *data;141141-#ifdef CONFIG_PPC_ISERIES142142- struct list_head Device_List;143143-#endif144144-};145145-146146-extern struct device_node *of_chosen;147147-148148-/* flag descriptions */149149-#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */150150-151151-#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)152152-#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)153153-154154-/*155155- * Until 32-bit ppc can add proc_dir_entries to its device_node156156- * definition, we cannot refer to pde, name_link, and addr_link157157- * in arch-independent code.158158- */159159-#define HAVE_ARCH_DEVTREE_FIXUPS160160-161161-static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)162162-{163163- dn->pde = de;164164-}165165-166166-167167-/* OBSOLETE: Old stlye node lookup */168168-extern struct device_node *find_devices(const char *name);169169-extern struct device_node *find_type_devices(const char *type);170170-extern struct device_node *find_path_device(const char *path);171171-extern struct device_node *find_compatible_devices(const char *type,172172- const char *compat);173173-extern struct device_node *find_all_nodes(void);174174-175175-/* New style node lookup */176176-extern struct device_node *of_find_node_by_name(struct device_node *from,177177- const char *name);178178-extern struct device_node *of_find_node_by_type(struct device_node *from,179179- const char *type);180180-extern struct device_node *of_find_compatible_node(struct device_node *from,181181- const char *type, const char *compat);182182-extern struct device_node *of_find_node_by_path(const char *path);183183-extern struct device_node *of_find_node_by_phandle(phandle handle);184184-extern struct device_node *of_find_all_nodes(struct device_node *prev);185185-extern struct device_node *of_get_parent(const struct device_node *node);186186-extern struct device_node *of_get_next_child(const struct device_node *node,187187- struct device_node *prev);188188-extern struct device_node *of_node_get(struct device_node *node);189189-extern void of_node_put(struct device_node *node);190190-191191-/* For scanning the flat device-tree at boot time */192192-int __init of_scan_flat_dt(int (*it)(unsigned long node,193193- const char *uname, int depth,194194- void *data),195195- void *data);196196-void* __init of_get_flat_dt_prop(unsigned long node, const char *name,197197- unsigned long *size);198198-199199-/* For updating the device tree at runtime */200200-extern void of_attach_node(struct device_node *);201201-extern void of_detach_node(const struct device_node *);202202-203203-/* Other Prototypes */204204-extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,205205- unsigned long, unsigned long);206206-extern void finish_device_tree(void);207207-extern void unflatten_device_tree(void);208208-extern void early_init_devtree(void *);209209-extern int device_is_compatible(struct device_node *device, const char *);210210-extern int machine_is_compatible(const char *compat);211211-extern unsigned char *get_property(struct device_node *node, const char *name,212212- int *lenp);213213-extern void print_properties(struct device_node *node);214214-extern int prom_n_addr_cells(struct device_node* np);215215-extern int prom_n_size_cells(struct device_node* np);216216-extern int prom_n_intr_cells(struct device_node* np);217217-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);218218-extern int prom_add_property(struct device_node* np, struct property* prop);219219-220220-#endif /* _PPC64_PROM_H */
···11/*22- * include/asm-ppc64/serial.h33- */44-#ifndef _PPC64_SERIAL_H55-#define _PPC64_SERIAL_H66-77-/*88- * This assumes you have a 1.8432 MHz clock for your UART.99- *1010- * It'd be nice if someone built a serial card with a 24.576 MHz1111- * clock, since the 16550A is capable of handling a top speed of 1.51212- * megabits/second; but this requires the faster clock.1313- *142 * This program is free software; you can redistribute it and/or153 * modify it under the terms of the GNU General Public License164 * as published by the Free Software Foundation; either version175 * 2 of the License, or (at your option) any later version.66+ */77+#ifndef _ASM_POWERPC_SERIAL_H88+#define _ASM_POWERPC_SERIAL_H99+1010+/*1111+ * Serial ports are not listed here, because they are discovered1212+ * through the device tree.1813 */19142015/* Default baud base if not found in device-tree */
-310
include/asm-ppc64/system.h
···11-#ifndef __PPC64_SYSTEM_H22-#define __PPC64_SYSTEM_H33-44-/*55- * This program is free software; you can redistribute it and/or66- * modify it under the terms of the GNU General Public License77- * as published by the Free Software Foundation; either version88- * 2 of the License, or (at your option) any later version.99- */1010-1111-#include <linux/config.h>1212-#include <linux/compiler.h>1313-#include <asm/page.h>1414-#include <asm/processor.h>1515-#include <asm/hw_irq.h>1616-#include <asm/synch.h>1717-1818-/*1919- * Memory barrier.2020- * The sync instruction guarantees that all memory accesses initiated2121- * by this processor have been performed (with respect to all other2222- * mechanisms that access memory). The eieio instruction is a barrier2323- * providing an ordering (separately) for (a) cacheable stores and (b)2424- * loads and stores to non-cacheable memory (e.g. I/O devices).2525- *2626- * mb() prevents loads and stores being reordered across this point.2727- * rmb() prevents loads being reordered across this point.2828- * wmb() prevents stores being reordered across this point.2929- * read_barrier_depends() prevents data-dependent loads being reordered3030- * across this point (nop on PPC).3131- *3232- * We have to use the sync instructions for mb(), since lwsync doesn't3333- * order loads with respect to previous stores. Lwsync is fine for3434- * rmb(), though.3535- * For wmb(), we use sync since wmb is used in drivers to order3636- * stores to system memory with respect to writes to the device.3737- * However, smp_wmb() can be a lighter-weight eieio barrier on3838- * SMP since it is only used to order updates to system memory.3939- */4040-#define mb() __asm__ __volatile__ ("sync" : : : "memory")4141-#define rmb() __asm__ __volatile__ ("lwsync" : : : "memory")4242-#define wmb() __asm__ __volatile__ ("sync" : : : "memory")4343-#define read_barrier_depends() do { } while(0)4444-4545-#define set_mb(var, value) do { var = value; smp_mb(); } while (0)4646-#define set_wmb(var, value) do { var = value; smp_wmb(); } while (0)4747-4848-#ifdef CONFIG_SMP4949-#define smp_mb() mb()5050-#define smp_rmb() rmb()5151-#define smp_wmb() eieio()5252-#define smp_read_barrier_depends() read_barrier_depends()5353-#else5454-#define smp_mb() __asm__ __volatile__("": : :"memory")5555-#define smp_rmb() __asm__ __volatile__("": : :"memory")5656-#define smp_wmb() __asm__ __volatile__("": : :"memory")5757-#define smp_read_barrier_depends() do { } while(0)5858-#endif /* CONFIG_SMP */5959-6060-#ifdef __KERNEL__6161-struct task_struct;6262-struct pt_regs;6363-6464-#ifdef CONFIG_DEBUGGER6565-6666-extern int (*__debugger)(struct pt_regs *regs);6767-extern int (*__debugger_ipi)(struct pt_regs *regs);6868-extern int (*__debugger_bpt)(struct pt_regs *regs);6969-extern int (*__debugger_sstep)(struct pt_regs *regs);7070-extern int (*__debugger_iabr_match)(struct pt_regs *regs);7171-extern int (*__debugger_dabr_match)(struct pt_regs *regs);7272-extern int (*__debugger_fault_handler)(struct pt_regs *regs);7373-7474-#define DEBUGGER_BOILERPLATE(__NAME) \7575-static inline int __NAME(struct pt_regs *regs) \7676-{ \7777- if (unlikely(__ ## __NAME)) \7878- return __ ## __NAME(regs); \7979- return 0; \8080-}8181-8282-DEBUGGER_BOILERPLATE(debugger)8383-DEBUGGER_BOILERPLATE(debugger_ipi)8484-DEBUGGER_BOILERPLATE(debugger_bpt)8585-DEBUGGER_BOILERPLATE(debugger_sstep)8686-DEBUGGER_BOILERPLATE(debugger_iabr_match)8787-DEBUGGER_BOILERPLATE(debugger_dabr_match)8888-DEBUGGER_BOILERPLATE(debugger_fault_handler)8989-9090-#ifdef CONFIG_XMON9191-extern void xmon_init(int enable);9292-#endif9393-9494-#else9595-static inline int debugger(struct pt_regs *regs) { return 0; }9696-static inline int debugger_ipi(struct pt_regs *regs) { return 0; }9797-static inline int debugger_bpt(struct pt_regs *regs) { return 0; }9898-static inline int debugger_sstep(struct pt_regs *regs) { return 0; }9999-static inline int debugger_iabr_match(struct pt_regs *regs) { return 0; }100100-static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; }101101-static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }102102-#endif103103-104104-extern int set_dabr(unsigned long dabr);105105-extern void _exception(int signr, struct pt_regs *regs, int code,106106- unsigned long addr);107107-extern int fix_alignment(struct pt_regs *regs);108108-extern void bad_page_fault(struct pt_regs *regs, unsigned long address,109109- int sig);110110-extern void show_regs(struct pt_regs * regs);111111-extern void low_hash_fault(struct pt_regs *regs, unsigned long address);112112-extern int die(const char *str, struct pt_regs *regs, long err);113113-114114-extern int _get_PVR(void);115115-extern void giveup_fpu(struct task_struct *);116116-extern void disable_kernel_fp(void);117117-extern void flush_fp_to_thread(struct task_struct *);118118-extern void enable_kernel_fp(void);119119-extern void giveup_altivec(struct task_struct *);120120-extern void disable_kernel_altivec(void);121121-extern void enable_kernel_altivec(void);122122-extern int emulate_altivec(struct pt_regs *);123123-extern void cvt_fd(float *from, double *to, struct thread_struct *thread);124124-extern void cvt_df(double *from, float *to, struct thread_struct *thread);125125-126126-#ifdef CONFIG_ALTIVEC127127-extern void flush_altivec_to_thread(struct task_struct *);128128-#else129129-static inline void flush_altivec_to_thread(struct task_struct *t)130130-{131131-}132132-#endif133133-134134-static inline void flush_spe_to_thread(struct task_struct *t)135135-{136136-}137137-138138-extern int mem_init_done; /* set on boot once kmalloc can be called */139139-extern unsigned long memory_limit;140140-141141-/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */142142-extern unsigned char e2a(unsigned char);143143-144144-extern struct task_struct *__switch_to(struct task_struct *,145145- struct task_struct *);146146-#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))147147-148148-struct thread_struct;149149-extern struct task_struct * _switch(struct thread_struct *prev,150150- struct thread_struct *next);151151-152152-extern unsigned long klimit;153153-154154-extern int powersave_nap; /* set if nap mode can be used in idle loop */155155-156156-/*157157- * Atomic exchange158158- *159159- * Changes the memory location '*ptr' to be val and returns160160- * the previous value stored there.161161- *162162- * Inline asm pulled from arch/ppc/kernel/misc.S so ppc64163163- * is more like most of the other architectures.164164- */165165-static __inline__ unsigned long166166-__xchg_u32(volatile unsigned int *m, unsigned long val)167167-{168168- unsigned long dummy;169169-170170- __asm__ __volatile__(171171- EIEIO_ON_SMP172172-"1: lwarx %0,0,%3 # __xchg_u32\n\173173- stwcx. %2,0,%3\n\174174-2: bne- 1b"175175- ISYNC_ON_SMP176176- : "=&r" (dummy), "=m" (*m)177177- : "r" (val), "r" (m)178178- : "cc", "memory");179179-180180- return (dummy);181181-}182182-183183-static __inline__ unsigned long184184-__xchg_u64(volatile long *m, unsigned long val)185185-{186186- unsigned long dummy;187187-188188- __asm__ __volatile__(189189- EIEIO_ON_SMP190190-"1: ldarx %0,0,%3 # __xchg_u64\n\191191- stdcx. %2,0,%3\n\192192-2: bne- 1b"193193- ISYNC_ON_SMP194194- : "=&r" (dummy), "=m" (*m)195195- : "r" (val), "r" (m)196196- : "cc", "memory");197197-198198- return (dummy);199199-}200200-201201-/*202202- * This function doesn't exist, so you'll get a linker error203203- * if something tries to do an invalid xchg().204204- */205205-extern void __xchg_called_with_bad_pointer(void);206206-207207-static __inline__ unsigned long208208-__xchg(volatile void *ptr, unsigned long x, unsigned int size)209209-{210210- switch (size) {211211- case 4:212212- return __xchg_u32(ptr, x);213213- case 8:214214- return __xchg_u64(ptr, x);215215- }216216- __xchg_called_with_bad_pointer();217217- return x;218218-}219219-220220-#define xchg(ptr,x) \221221- ({ \222222- __typeof__(*(ptr)) _x_ = (x); \223223- (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \224224- })225225-226226-#define tas(ptr) (xchg((ptr),1))227227-228228-#define __HAVE_ARCH_CMPXCHG 1229229-230230-static __inline__ unsigned long231231-__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)232232-{233233- unsigned int prev;234234-235235- __asm__ __volatile__ (236236- EIEIO_ON_SMP237237-"1: lwarx %0,0,%2 # __cmpxchg_u32\n\238238- cmpw 0,%0,%3\n\239239- bne- 2f\n\240240- stwcx. %4,0,%2\n\241241- bne- 1b"242242- ISYNC_ON_SMP243243- "\n\244244-2:"245245- : "=&r" (prev), "=m" (*p)246246- : "r" (p), "r" (old), "r" (new), "m" (*p)247247- : "cc", "memory");248248-249249- return prev;250250-}251251-252252-static __inline__ unsigned long253253-__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new)254254-{255255- unsigned long prev;256256-257257- __asm__ __volatile__ (258258- EIEIO_ON_SMP259259-"1: ldarx %0,0,%2 # __cmpxchg_u64\n\260260- cmpd 0,%0,%3\n\261261- bne- 2f\n\262262- stdcx. %4,0,%2\n\263263- bne- 1b"264264- ISYNC_ON_SMP265265- "\n\266266-2:"267267- : "=&r" (prev), "=m" (*p)268268- : "r" (p), "r" (old), "r" (new), "m" (*p)269269- : "cc", "memory");270270-271271- return prev;272272-}273273-274274-/* This function doesn't exist, so you'll get a linker error275275- if something tries to do an invalid cmpxchg(). */276276-extern void __cmpxchg_called_with_bad_pointer(void);277277-278278-static __inline__ unsigned long279279-__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,280280- unsigned int size)281281-{282282- switch (size) {283283- case 4:284284- return __cmpxchg_u32(ptr, old, new);285285- case 8:286286- return __cmpxchg_u64(ptr, old, new);287287- }288288- __cmpxchg_called_with_bad_pointer();289289- return old;290290-}291291-292292-#define cmpxchg(ptr,o,n)\293293- ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\294294- (unsigned long)(n),sizeof(*(ptr))))295295-296296-/*297297- * We handle most unaligned accesses in hardware. On the other hand 298298- * unaligned DMA can be very expensive on some ppc64 IO chips (it does299299- * powers of 2 writes until it reaches sufficient alignment).300300- *301301- * Based on this we disable the IP header alignment in network drivers.302302- */303303-#define NET_IP_ALIGN 0304304-305305-#define arch_align_stack(x) (x)306306-307307-extern unsigned long reloc_offset(void);308308-309309-#endif /* __KERNEL__ */310310-#endif