Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _ASM_POWERPC_MACHDEP_H
0003 #define _ASM_POWERPC_MACHDEP_H
0004 #ifdef __KERNEL__
0005 
0006 #include <linux/seq_file.h>
0007 #include <linux/init.h>
0008 #include <linux/dma-mapping.h>
0009 #include <linux/export.h>
0010 
0011 struct pt_regs;
0012 struct pci_bus; 
0013 struct device_node;
0014 struct iommu_table;
0015 struct rtc_time;
0016 struct file;
0017 struct pci_controller;
0018 struct kimage;
0019 struct pci_host_bridge;
0020 
0021 struct machdep_calls {
0022     char        *name;
0023 #ifdef CONFIG_PPC64
0024 #ifdef CONFIG_PM
0025     void        (*iommu_restore)(void);
0026 #endif
0027 #ifdef CONFIG_MEMORY_HOTPLUG
0028     unsigned long   (*memory_block_size)(void);
0029 #endif
0030 #endif /* CONFIG_PPC64 */
0031 
0032     void        (*dma_set_mask)(struct device *dev, u64 dma_mask);
0033 
0034     int     (*probe)(void);
0035     void        (*setup_arch)(void); /* Optional, may be NULL */
0036     /* Optional, may be NULL. */
0037     void        (*show_cpuinfo)(struct seq_file *m);
0038     /* Returns the current operating frequency of "cpu" in Hz */
0039     unsigned long   (*get_proc_freq)(unsigned int cpu);
0040 
0041     void        (*init_IRQ)(void);
0042 
0043     /* Return an irq, or 0 to indicate there are none pending. */
0044     unsigned int    (*get_irq)(void);
0045 
0046     /* PCI stuff */
0047     /* Called after allocating resources */
0048     void        (*pcibios_fixup)(void);
0049     void        (*pci_irq_fixup)(struct pci_dev *dev);
0050     int     (*pcibios_root_bridge_prepare)(struct pci_host_bridge
0051                 *bridge);
0052 
0053     /* finds all the pci_controllers present at boot */
0054     void        (*discover_phbs)(void);
0055 
0056     /* To setup PHBs when using automatic OF platform driver for PCI */
0057     int     (*pci_setup_phb)(struct pci_controller *host);
0058 
0059     void __noreturn (*restart)(char *cmd);
0060     void __noreturn (*halt)(void);
0061     void        (*panic)(char *str);
0062 
0063     long        (*time_init)(void); /* Optional, may be NULL */
0064 
0065     int     (*set_rtc_time)(struct rtc_time *);
0066     void        (*get_rtc_time)(struct rtc_time *);
0067     time64_t    (*get_boot_time)(void);
0068 
0069     void        (*calibrate_decr)(void);
0070 
0071     void        (*progress)(char *, unsigned short);
0072 
0073     /* Interface for platform error logging */
0074     void        (*log_error)(char *buf, unsigned int err_type, int fatal);
0075 
0076     unsigned char   (*nvram_read_val)(int addr);
0077     void        (*nvram_write_val)(int addr, unsigned char val);
0078     ssize_t     (*nvram_write)(char *buf, size_t count, loff_t *index);
0079     ssize_t     (*nvram_read)(char *buf, size_t count, loff_t *index);  
0080     ssize_t     (*nvram_size)(void);        
0081     void        (*nvram_sync)(void);
0082 
0083     /* Exception handlers */
0084     int     (*system_reset_exception)(struct pt_regs *regs);
0085     int         (*machine_check_exception)(struct pt_regs *regs);
0086     int     (*handle_hmi_exception)(struct pt_regs *regs);
0087 
0088     /* Early exception handlers called in realmode */
0089     int     (*hmi_exception_early)(struct pt_regs *regs);
0090     long        (*machine_check_early)(struct pt_regs *regs);
0091 
0092     /* Called during machine check exception to retrive fixup address. */
0093     bool        (*mce_check_early_recovery)(struct pt_regs *regs);
0094 
0095     void            (*machine_check_log_err)(void);
0096 
0097     /* Motherboard/chipset features. This is a kind of general purpose
0098      * hook used to control some machine specific features (like reset
0099      * lines, chip power control, etc...).
0100      */
0101     long        (*feature_call)(unsigned int feature, ...);
0102 
0103     /* Get legacy PCI/IDE interrupt mapping */ 
0104     int     (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
0105     
0106     /* Get access protection for /dev/mem */
0107     pgprot_t    (*phys_mem_access_prot)(struct file *file,
0108                         unsigned long pfn,
0109                         unsigned long size,
0110                         pgprot_t vma_prot);
0111 
0112     /*
0113      * Function for waiting for work with reduced power in idle loop;
0114      * called with interrupts disabled.
0115      */
0116     void        (*power_save)(void);
0117 
0118     /* Function to enable performance monitor counters for this
0119        platform, called once per cpu. */
0120     void        (*enable_pmcs)(void);
0121 
0122     /* Set DABR for this platform, leave empty for default implementation */
0123     int     (*set_dabr)(unsigned long dabr,
0124                     unsigned long dabrx);
0125 
0126     /* Set DAWR for this platform, leave empty for default implementation */
0127     int     (*set_dawr)(int nr, unsigned long dawr,
0128                     unsigned long dawrx);
0129 
0130 #ifdef CONFIG_PPC32 /* XXX for now */
0131     /* A general init function, called by ppc_init in init/main.c.
0132        May be NULL. */
0133     void        (*init)(void);
0134 
0135     /*
0136      * optional PCI "hooks"
0137      */
0138     /* Called at then very end of pcibios_init() */
0139     void (*pcibios_after_init)(void);
0140 
0141 #endif /* CONFIG_PPC32 */
0142 
0143     /* Called in indirect_* to avoid touching devices */
0144     int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
0145 
0146     /* Called after PPC generic resource fixup to perform
0147        machine specific fixups */
0148     void (*pcibios_fixup_resources)(struct pci_dev *);
0149 
0150     /* Called for each PCI bus in the system when it's probed */
0151     void (*pcibios_fixup_bus)(struct pci_bus *);
0152 
0153     /* Called after scan and before resource survey */
0154     void (*pcibios_fixup_phb)(struct pci_controller *hose);
0155 
0156     /*
0157      * Called after device has been added to bus and
0158      * before sysfs has been created.
0159      */
0160     void (*pcibios_bus_add_device)(struct pci_dev *pdev);
0161 
0162     resource_size_t (*pcibios_default_alignment)(void);
0163 
0164 #ifdef CONFIG_PCI_IOV
0165     void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
0166     resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
0167     int (*pcibios_sriov_enable)(struct pci_dev *pdev, u16 num_vfs);
0168     int (*pcibios_sriov_disable)(struct pci_dev *pdev);
0169 #endif /* CONFIG_PCI_IOV */
0170 
0171     /* Called to shutdown machine specific hardware not already controlled
0172      * by other drivers.
0173      */
0174     void (*machine_shutdown)(void);
0175 
0176 #ifdef CONFIG_KEXEC_CORE
0177     void (*kexec_cpu_down)(int crash_shutdown, int secondary);
0178 
0179     /* Called to perform the _real_ kexec.
0180      * Do NOT allocate memory or fail here. We are past the point of
0181      * no return.
0182      */
0183     void (*machine_kexec)(struct kimage *image);
0184 #endif /* CONFIG_KEXEC_CORE */
0185 
0186 #ifdef CONFIG_SUSPEND
0187     /* These are called to disable and enable, respectively, IRQs when
0188      * entering a suspend state.  If NULL, then the generic versions
0189      * will be called.  The generic versions disable/enable the
0190      * decrementer along with interrupts.
0191      */
0192     void (*suspend_disable_irqs)(void);
0193     void (*suspend_enable_irqs)(void);
0194 #endif
0195 
0196 #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
0197     ssize_t (*cpu_probe)(const char *, size_t);
0198     ssize_t (*cpu_release)(const char *, size_t);
0199 #endif
0200 
0201     int (*get_random_seed)(unsigned long *v);
0202 };
0203 
0204 extern void e500_idle(void);
0205 extern void power4_idle(void);
0206 extern void ppc6xx_idle(void);
0207 extern void book3e_idle(void);
0208 
0209 /*
0210  * ppc_md contains a copy of the machine description structure for the
0211  * current platform. machine_id contains the initial address where the
0212  * description was found during boot.
0213  */
0214 extern struct machdep_calls ppc_md;
0215 extern struct machdep_calls *machine_id;
0216 
0217 #define __machine_desc __section(".machine.desc")
0218 
0219 #define define_machine(name)                    \
0220     extern struct machdep_calls mach_##name;        \
0221     EXPORT_SYMBOL(mach_##name);             \
0222     struct machdep_calls mach_##name __machine_desc =
0223 
0224 #define machine_is(name) \
0225     ({ \
0226         extern struct machdep_calls mach_##name \
0227             __attribute__((weak));       \
0228         machine_id == &mach_##name; \
0229     })
0230 
0231 static inline void log_error(char *buf, unsigned int err_type, int fatal)
0232 {
0233     if (ppc_md.log_error)
0234         ppc_md.log_error(buf, err_type, fatal);
0235 }
0236 
0237 #define __define_machine_initcall(mach, fn, id) \
0238     static int __init __machine_initcall_##mach##_##fn(void) { \
0239         if (machine_is(mach)) return fn(); \
0240         return 0; \
0241     } \
0242     __define_initcall(__machine_initcall_##mach##_##fn, id);
0243 
0244 #define machine_early_initcall(mach, fn)    __define_machine_initcall(mach, fn, early)
0245 #define machine_core_initcall(mach, fn)     __define_machine_initcall(mach, fn, 1)
0246 #define machine_core_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 1s)
0247 #define machine_postcore_initcall(mach, fn) __define_machine_initcall(mach, fn, 2)
0248 #define machine_postcore_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 2s)
0249 #define machine_arch_initcall(mach, fn)     __define_machine_initcall(mach, fn, 3)
0250 #define machine_arch_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 3s)
0251 #define machine_subsys_initcall(mach, fn)   __define_machine_initcall(mach, fn, 4)
0252 #define machine_subsys_initcall_sync(mach, fn)  __define_machine_initcall(mach, fn, 4s)
0253 #define machine_fs_initcall(mach, fn)       __define_machine_initcall(mach, fn, 5)
0254 #define machine_fs_initcall_sync(mach, fn)  __define_machine_initcall(mach, fn, 5s)
0255 #define machine_rootfs_initcall(mach, fn)   __define_machine_initcall(mach, fn, rootfs)
0256 #define machine_device_initcall(mach, fn)   __define_machine_initcall(mach, fn, 6)
0257 #define machine_device_initcall_sync(mach, fn)  __define_machine_initcall(mach, fn, 6s)
0258 #define machine_late_initcall(mach, fn)     __define_machine_initcall(mach, fn, 7)
0259 #define machine_late_initcall_sync(mach, fn)    __define_machine_initcall(mach, fn, 7s)
0260 
0261 #endif /* __KERNEL__ */
0262 #endif /* _ASM_POWERPC_MACHDEP_H */