linux/arch/powerpc/include/asm/machdep.h
<<
>>
Prefs
   1#ifndef _ASM_POWERPC_MACHDEP_H
   2#define _ASM_POWERPC_MACHDEP_H
   3#ifdef __KERNEL__
   4
   5/*
   6 * This program is free software; you can redistribute it and/or
   7 * modify it under the terms of the GNU General Public License
   8 * as published by the Free Software Foundation; either version
   9 * 2 of the License, or (at your option) any later version.
  10 */
  11
  12#include <linux/seq_file.h>
  13#include <linux/init.h>
  14#include <linux/dma-mapping.h>
  15#include <linux/export.h>
  16
  17#include <asm/setup.h>
  18
  19/* We export this macro for external modules like Alsa to know if
  20 * ppc_md.feature_call is implemented or not
  21 */
  22#define CONFIG_PPC_HAS_FEATURE_CALLS
  23
  24struct pt_regs;
  25struct pci_bus; 
  26struct device_node;
  27struct iommu_table;
  28struct rtc_time;
  29struct file;
  30struct pci_controller;
  31struct kimage;
  32struct pci_host_bridge;
  33
  34struct machdep_calls {
  35        char            *name;
  36#ifdef CONFIG_PPC64
  37        void            (*hpte_invalidate)(unsigned long slot,
  38                                           unsigned long vpn,
  39                                           int bpsize, int apsize,
  40                                           int ssize, int local);
  41        long            (*hpte_updatepp)(unsigned long slot, 
  42                                         unsigned long newpp, 
  43                                         unsigned long vpn,
  44                                         int bpsize, int apsize,
  45                                         int ssize, unsigned long flags);
  46        void            (*hpte_updateboltedpp)(unsigned long newpp, 
  47                                               unsigned long ea,
  48                                               int psize, int ssize);
  49        long            (*hpte_insert)(unsigned long hpte_group,
  50                                       unsigned long vpn,
  51                                       unsigned long prpn,
  52                                       unsigned long rflags,
  53                                       unsigned long vflags,
  54                                       int psize, int apsize,
  55                                       int ssize);
  56        long            (*hpte_remove)(unsigned long hpte_group);
  57        void            (*hpte_removebolted)(unsigned long ea,
  58                                             int psize, int ssize);
  59        void            (*flush_hash_range)(unsigned long number, int local);
  60        void            (*hugepage_invalidate)(unsigned long vsid,
  61                                               unsigned long addr,
  62                                               unsigned char *hpte_slot_array,
  63                                               int psize, int ssize);
  64        int             (*resize_hpt)(unsigned long shift);
  65        /* special for kexec, to be called in real mode, linear mapping is
  66         * destroyed as well */
  67        void            (*hpte_clear_all)(void);
  68
  69        void __iomem *  (*ioremap)(phys_addr_t addr, unsigned long size,
  70                                   unsigned long flags, void *caller);
  71        void            (*iounmap)(volatile void __iomem *token);
  72
  73#ifdef CONFIG_PM
  74        void            (*iommu_save)(void);
  75        void            (*iommu_restore)(void);
  76#endif
  77#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
  78        unsigned long   (*memory_block_size)(void);
  79#endif
  80#endif /* CONFIG_PPC64 */
  81
  82        /* Platform set_dma_mask and dma_get_required_mask overrides */
  83        int             (*dma_set_mask)(struct device *dev, u64 dma_mask);
  84        u64             (*dma_get_required_mask)(struct device *dev);
  85
  86        int             (*probe)(void);
  87        void            (*setup_arch)(void); /* Optional, may be NULL */
  88        void            (*init_early)(void);
  89        /* Optional, may be NULL. */
  90        void            (*show_cpuinfo)(struct seq_file *m);
  91        void            (*show_percpuinfo)(struct seq_file *m, int i);
  92        /* Returns the current operating frequency of "cpu" in Hz */
  93        unsigned long   (*get_proc_freq)(unsigned int cpu);
  94
  95        void            (*init_IRQ)(void);
  96
  97        /* Return an irq, or NO_IRQ to indicate there are none pending. */
  98        unsigned int    (*get_irq)(void);
  99
 100        /* PCI stuff */
 101        /* Called after scanning the bus, before allocating resources */
 102        void            (*pcibios_fixup)(void);
 103        void            (*pci_irq_fixup)(struct pci_dev *dev);
 104        int             (*pcibios_root_bridge_prepare)(struct pci_host_bridge
 105                                *bridge);
 106
 107        /* To setup PHBs when using automatic OF platform driver for PCI */
 108        int             (*pci_setup_phb)(struct pci_controller *host);
 109
 110        void            (*restart)(char *cmd);
 111        void            (*power_off)(void);
 112        void            (*halt)(void);
 113        void            (*panic)(char *str);
 114        void            (*cpu_die)(void);
 115
 116        long            (*time_init)(void); /* Optional, may be NULL */
 117
 118        int             (*set_rtc_time)(struct rtc_time *);
 119        void            (*get_rtc_time)(struct rtc_time *);
 120        unsigned long   (*get_boot_time)(void);
 121        unsigned char   (*rtc_read_val)(int addr);
 122        void            (*rtc_write_val)(int addr, unsigned char val);
 123
 124        void            (*calibrate_decr)(void);
 125
 126        void            (*progress)(char *, unsigned short);
 127
 128        /* Interface for platform error logging */
 129        void            (*log_error)(char *buf, unsigned int err_type, int fatal);
 130
 131        unsigned char   (*nvram_read_val)(int addr);
 132        void            (*nvram_write_val)(int addr, unsigned char val);
 133        ssize_t         (*nvram_write)(char *buf, size_t count, loff_t *index);
 134        ssize_t         (*nvram_read)(char *buf, size_t count, loff_t *index);  
 135        ssize_t         (*nvram_size)(void);            
 136        void            (*nvram_sync)(void);
 137
 138        /* Exception handlers */
 139        int             (*system_reset_exception)(struct pt_regs *regs);
 140        int             (*machine_check_exception)(struct pt_regs *regs);
 141        int             (*handle_hmi_exception)(struct pt_regs *regs);
 142
 143        /* Early exception handlers called in realmode */
 144        int             (*hmi_exception_early)(struct pt_regs *regs);
 145
 146        /* Called during machine check exception to retrive fixup address. */
 147        bool            (*mce_check_early_recovery)(struct pt_regs *regs);
 148
 149        /* Motherboard/chipset features. This is a kind of general purpose
 150         * hook used to control some machine specific features (like reset
 151         * lines, chip power control, etc...).
 152         */
 153        long            (*feature_call)(unsigned int feature, ...);
 154
 155        /* Get legacy PCI/IDE interrupt mapping */ 
 156        int             (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
 157        
 158        /* Get access protection for /dev/mem */
 159        pgprot_t        (*phys_mem_access_prot)(struct file *file,
 160                                                unsigned long pfn,
 161                                                unsigned long size,
 162                                                pgprot_t vma_prot);
 163
 164        /*
 165         * Function for waiting for work with reduced power in idle loop;
 166         * called with interrupts disabled.
 167         */
 168        void            (*power_save)(void);
 169
 170        /* Function to enable performance monitor counters for this
 171           platform, called once per cpu. */
 172        void            (*enable_pmcs)(void);
 173
 174        /* Set DABR for this platform, leave empty for default implemenation */
 175        int             (*set_dabr)(unsigned long dabr,
 176                                    unsigned long dabrx);
 177
 178        /* Set DAWR for this platform, leave empty for default implemenation */
 179        int             (*set_dawr)(unsigned long dawr,
 180                                    unsigned long dawrx);
 181
 182#ifdef CONFIG_PPC32     /* XXX for now */
 183        /* A general init function, called by ppc_init in init/main.c.
 184           May be NULL. */
 185        void            (*init)(void);
 186
 187        void            (*kgdb_map_scc)(void);
 188
 189        /*
 190         * optional PCI "hooks"
 191         */
 192        /* Called at then very end of pcibios_init() */
 193        void (*pcibios_after_init)(void);
 194
 195#endif /* CONFIG_PPC32 */
 196
 197        /* Called in indirect_* to avoid touching devices */
 198        int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
 199
 200        /* Called after PPC generic resource fixup to perform
 201           machine specific fixups */
 202        void (*pcibios_fixup_resources)(struct pci_dev *);
 203
 204        /* Called for each PCI bus in the system when it's probed */
 205        void (*pcibios_fixup_bus)(struct pci_bus *);
 206
 207        /* Called after scan and before resource survey */
 208        void (*pcibios_fixup_phb)(struct pci_controller *hose);
 209
 210#ifdef CONFIG_PCI_IOV
 211        void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
 212        resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
 213#endif /* CONFIG_PCI_IOV */
 214
 215        /* Called to shutdown machine specific hardware not already controlled
 216         * by other drivers.
 217         */
 218        void (*machine_shutdown)(void);
 219
 220#ifdef CONFIG_KEXEC
 221        void (*kexec_cpu_down)(int crash_shutdown, int secondary);
 222
 223        /* Called to do what every setup is needed on image and the
 224         * reboot code buffer. Returns 0 on success.
 225         * Provide your own (maybe dummy) implementation if your platform
 226         * claims to support kexec.
 227         */
 228        int (*machine_kexec_prepare)(struct kimage *image);
 229
 230        /* Called to perform the _real_ kexec.
 231         * Do NOT allocate memory or fail here. We are past the point of
 232         * no return.
 233         */
 234        void (*machine_kexec)(struct kimage *image);
 235#endif /* CONFIG_KEXEC */
 236
 237#ifdef CONFIG_SUSPEND
 238        /* These are called to disable and enable, respectively, IRQs when
 239         * entering a suspend state.  If NULL, then the generic versions
 240         * will be called.  The generic versions disable/enable the
 241         * decrementer along with interrupts.
 242         */
 243        void (*suspend_disable_irqs)(void);
 244        void (*suspend_enable_irqs)(void);
 245#endif
 246        int (*suspend_disable_cpu)(void);
 247
 248#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
 249        ssize_t (*cpu_probe)(const char *, size_t);
 250        ssize_t (*cpu_release)(const char *, size_t);
 251#endif
 252
 253#ifdef CONFIG_ARCH_RANDOM
 254        int (*get_random_long)(unsigned long *v);
 255#endif
 256};
 257
 258extern void e500_idle(void);
 259extern void power4_idle(void);
 260extern void power7_idle(void);
 261extern void ppc6xx_idle(void);
 262extern void book3e_idle(void);
 263
 264/*
 265 * ppc_md contains a copy of the machine description structure for the
 266 * current platform. machine_id contains the initial address where the
 267 * description was found during boot.
 268 */
 269extern struct machdep_calls ppc_md;
 270extern struct machdep_calls *machine_id;
 271
 272#define __machine_desc __attribute__ ((__section__ (".machine.desc")))
 273
 274#define define_machine(name)                                    \
 275        extern struct machdep_calls mach_##name;                \
 276        EXPORT_SYMBOL(mach_##name);                             \
 277        struct machdep_calls mach_##name __machine_desc =
 278
 279#define machine_is(name) \
 280        ({ \
 281                extern struct machdep_calls mach_##name \
 282                        __attribute__((weak));           \
 283                machine_id == &mach_##name; \
 284        })
 285
 286extern void probe_machine(void);
 287
 288extern char cmd_line[COMMAND_LINE_SIZE];
 289
 290#ifdef CONFIG_PPC_PMAC
 291/*
 292 * Power macintoshes have either a CUDA, PMU or SMU controlling
 293 * system reset, power, NVRAM, RTC.
 294 */
 295typedef enum sys_ctrler_kind {
 296        SYS_CTRLER_UNKNOWN = 0,
 297        SYS_CTRLER_CUDA = 1,
 298        SYS_CTRLER_PMU = 2,
 299        SYS_CTRLER_SMU = 3,
 300} sys_ctrler_t;
 301extern sys_ctrler_t sys_ctrler;
 302
 303#endif /* CONFIG_PPC_PMAC */
 304
 305
 306/* Functions to produce codes on the leds.
 307 * The SRC code should be unique for the message category and should
 308 * be limited to the lower 24 bits (the upper 8 are set by these funcs),
 309 * and (for boot & dump) should be sorted numerically in the order
 310 * the events occur.
 311 */
 312/* Print a boot progress message. */
 313void ppc64_boot_msg(unsigned int src, const char *msg);
 314
 315static inline void log_error(char *buf, unsigned int err_type, int fatal)
 316{
 317        if (ppc_md.log_error)
 318                ppc_md.log_error(buf, err_type, fatal);
 319}
 320
 321#define __define_machine_initcall(mach, fn, id) \
 322        static int __init __machine_initcall_##mach##_##fn(void) { \
 323                if (machine_is(mach)) return fn(); \
 324                return 0; \
 325        } \
 326        __define_initcall(__machine_initcall_##mach##_##fn, id);
 327
 328#define machine_early_initcall(mach, fn)        __define_machine_initcall(mach, fn, early)
 329#define machine_core_initcall(mach, fn)         __define_machine_initcall(mach, fn, 1)
 330#define machine_core_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 1s)
 331#define machine_postcore_initcall(mach, fn)     __define_machine_initcall(mach, fn, 2)
 332#define machine_postcore_initcall_sync(mach, fn)        __define_machine_initcall(mach, fn, 2s)
 333#define machine_arch_initcall(mach, fn)         __define_machine_initcall(mach, fn, 3)
 334#define machine_arch_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 3s)
 335#define machine_subsys_initcall(mach, fn)       __define_machine_initcall(mach, fn, 4)
 336#define machine_subsys_initcall_sync(mach, fn)  __define_machine_initcall(mach, fn, 4s)
 337#define machine_fs_initcall(mach, fn)           __define_machine_initcall(mach, fn, 5)
 338#define machine_fs_initcall_sync(mach, fn)      __define_machine_initcall(mach, fn, 5s)
 339#define machine_rootfs_initcall(mach, fn)       __define_machine_initcall(mach, fn, rootfs)
 340#define machine_device_initcall(mach, fn)       __define_machine_initcall(mach, fn, 6)
 341#define machine_device_initcall_sync(mach, fn)  __define_machine_initcall(mach, fn, 6s)
 342#define machine_late_initcall(mach, fn)         __define_machine_initcall(mach, fn, 7)
 343#define machine_late_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 7s)
 344
 345#endif /* __KERNEL__ */
 346#endif /* _ASM_POWERPC_MACHDEP_H */
 347