1 /*
2  *   OpenBIOS driver prototypes
3  *
4  *   (C) 2004 Stefan Reinauer
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  *   version 2
9  *
10  */
11 #ifndef OPENBIOS_DRIVERS_H
12 #define OPENBIOS_DRIVERS_H
13 
14 #include "config.h"
15 
16 #ifdef CONFIG_DRIVER_PCI
17 /* drivers/pci.c */
18 int ob_pci_init(void);
19 #endif
20 
21 #if defined(CONFIG_DRIVER_PCI) || defined(CONFIG_DRIVER_ESCC)
22 #ifdef CONFIG_PPC
23 extern int is_apple(void);
24 extern int is_oldworld(void);
25 extern int is_newworld(void);
26 extern int has_pmu(void);
27 extern int has_adb(void);
28 #else
is_apple(void)29 static inline int is_apple(void)
30 {
31 	return 0;
32 }
is_oldworld(void)33 static inline int is_oldworld(void)
34 {
35 	return 0;
36 }
is_newworld(void)37 static inline int is_newworld(void)
38 {
39 	return 0;
40 }
has_pmu(void)41 static inline int has_pmu(void)
42 {
43 	return 0;
44 }
has_adb(void)45 static inline int has_adb(void)
46 {
47 	return 0;
48 }
49 #endif
50 #define AAPL(_cmd)      do { if (is_apple()) _cmd; } while(0)
51 #define OLDWORLD(_cmd)  do { if (is_oldworld()) _cmd; } while(0)
52 #define NEWWORLD(_cmd)  do { if (is_newworld()) _cmd; } while(0)
53 #endif
54 #ifdef CONFIG_DRIVER_SBUS
55 /* drivers/sbus.c */
56 int ob_sbus_init(uint64_t base, int machine_id);
57 
58 /* arch/sparc32/console.c */
59 void kbd_init(uint64_t base);
60 #endif
61 #ifdef CONFIG_DRIVER_IDE
62 /* drivers/ide.c */
63 int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
64                 uint32_t io_port1, uint32_t ctl_port1);
65 void ob_ide_quiesce(void);
66 int macio_ide_init(const char *path, uint32_t addr, int nb_channels);
67 #endif
68 #ifdef CONFIG_DRIVER_ESP
69 /* drivers/esp.c */
70 int ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset,
71                 unsigned long dmaoffset);
72 #endif
73 #ifdef CONFIG_DRIVER_LSI_53C810
74 /* drivers/lsi.c */
75 int ob_lsi_init(const char *path, uint64_t mmio, uint64_t ram);
76 #endif
77 #ifdef CONFIG_DRIVER_OBIO
78 /* drivers/obio.c */
79 int ob_obio_init(uint64_t slavio_base, unsigned long fd_offset,
80                  unsigned long counter_offset, unsigned long intr_offset,
81                  int intr_ncpu, unsigned long aux1_offset, unsigned long aux2_offset,
82                  unsigned long mem_size);
83 int start_cpu(unsigned int pc, unsigned int context_ptr, unsigned int context,
84               int cpu);
85 void ob_eccmemctl_init(uint64_t base);
86 void ss5_init(uint64_t base);
87 
88 /* drivers/iommu.c */
89 void ob_init_iommu(uint64_t base);
90 void *dvma_alloc(int size);
91 void dvma_sync(unsigned char *va, int size);
92 unsigned int dvma_map_in(unsigned char *va);
93 
94 /* drivers/sbus.c */
95 extern uint16_t graphic_depth;
96 
97 /* drivers/obio.c */
98 extern volatile unsigned char *power_reg;
99 extern volatile unsigned int *reset_reg;
100 extern volatile struct sun4m_timer_regs *counter_regs;
101 
102 void ob_new_obio_device(const char *name, const char *type);
103 unsigned long ob_reg(uint64_t base, uint64_t offset, unsigned long size, int map);
104 void ob_intr(int intr);
105 
106 /* arch/sparc32/boot.c */
107 extern uint32_t kernel_image;
108 extern uint32_t kernel_size;
109 extern uint32_t initrd_image;
110 extern uint32_t initrd_size;
111 extern uint32_t qemu_cmdline;
112 extern uint32_t cmdline_size;
113 extern char boot_device;
114 #endif
115 #ifdef CONFIG_DRIVER_FLOPPY
116 int ob_floppy_init(const char *path, const char *dev_name,
117                    unsigned long io_base, unsigned long mmio_base);
118 #endif
119 #ifdef CONFIG_DRIVER_PC_KBD
120 void ob_pc_kbd_init(const char *path, const char *kdev_name, const char *mdev_name,
121                     uint64_t base, uint64_t offset, int kintr, int mintr);
122 int pc_kbd_dataready(void);
123 unsigned char pc_kbd_readdata(void);
124 #endif
125 #ifdef CONFIG_DRIVER_PC_SERIAL
126 void ob_pc_serial_init(const char *path, const char *dev_name, uint64_t base,
127                        uint64_t offset, int intr);
128 int uart_init(int port, unsigned long speed);
129 int uart_charav(int port);
130 char uart_getchar(int port);
131 void uart_putchar(int c);
132 #endif
133 #ifdef CONFIG_DRIVER_ESCC
134 int escc_uart_init(phys_addr_t port, unsigned long speed);
135 int escc_uart_charav(uintptr_t port);
136 char escc_uart_getchar(uintptr_t port);
137 void escc_uart_putchar(int c);
138 void serial_cls(void);
139 #ifdef CONFIG_DRIVER_ESCC_SUN
140 int keyboard_dataready(void);
141 unsigned char keyboard_readdata(void);
142 #endif
143 #endif
144 #ifdef CONFIG_DRIVER_VIRTIO_BLK
145 void ob_virtio_init(const char *path, const char *dev_name, uint64_t common_cfg,
146                     uint64_t device_cfg, uint64_t notify_base, uint32_t notify_mult,
147                     int idx);
148 #endif
149 int macio_get_nvram_size(void);
150 void macio_nvram_put(char *buf);
151 void macio_nvram_get(char *buf);
152 void macio_nvram_init(const char *path, phys_addr_t addr);
153 void ob_unin_init(void);
154 
155 /* drivers/timer.c */
156 void setup_timers(void);
157 
158 #endif /* OPENBIOS_DRIVERS_H */
159