1 | /* General part of a AMBA Plug & Play bus driver. |
---|
2 | * |
---|
3 | * COPYRIGHT (c) 2008. |
---|
4 | * Cobham Gaisler AB |
---|
5 | * |
---|
6 | * This is the general part of the different AMBA Plug & Play |
---|
7 | * drivers. The drivers are wrappers around this driver, making |
---|
8 | * the code size smaller for systems with multiple AMBA Plug & |
---|
9 | * Play buses. |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef __AMBAPP_BUS_H__ |
---|
17 | #define __AMBAPP_BUS_H__ |
---|
18 | |
---|
19 | #include <drvmgr/drvmgr.h> |
---|
20 | #include <ambapp.h> |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | /* GRLIB AMBA Plug&Play Driver ID generation */ |
---|
27 | #define DRIVER_AMBAPP_ID(vendor, device) \ |
---|
28 | DRIVER_ID(DRVMGR_BUS_TYPE_AMBAPP, ((((vendor) & 0xff) << 16) | ((device) & 0xfff))) |
---|
29 | |
---|
30 | /*** Gaisler Hardware Device Driver IDs ***/ |
---|
31 | #define DRIVER_AMBAPP_GAISLER_APBUART_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_APBUART) |
---|
32 | #define DRIVER_AMBAPP_GAISLER_GPTIMER_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPTIMER) |
---|
33 | |
---|
34 | struct amba_dev_id { |
---|
35 | unsigned short vendor; |
---|
36 | unsigned short device; |
---|
37 | /* Version ? */ |
---|
38 | }; |
---|
39 | |
---|
40 | struct amba_drv_info { |
---|
41 | struct drvmgr_drv general; /* General bus info */ |
---|
42 | /* AMBA specific bus information */ |
---|
43 | struct amba_dev_id *ids; /* Supported hardware */ |
---|
44 | }; |
---|
45 | |
---|
46 | struct amba_dev_info { |
---|
47 | struct amba_dev_id id; |
---|
48 | struct ambapp_core info; |
---|
49 | }; |
---|
50 | |
---|
51 | struct ambapp_ops { |
---|
52 | int (*int_register) |
---|
53 | (struct drvmgr_dev *dev, int index, const char *info, drvmgr_isr isr, void *arg); |
---|
54 | int (*int_unregister) |
---|
55 | (struct drvmgr_dev *dev, int index, drvmgr_isr isr, void *arg); |
---|
56 | int (*int_clear)(struct drvmgr_dev *dev, int index); |
---|
57 | int (*int_mask)(struct drvmgr_dev *dev, int index); |
---|
58 | int (*int_unmask)(struct drvmgr_dev *dev, int index); |
---|
59 | int (*get_params) |
---|
60 | (struct drvmgr_dev *, struct drvmgr_bus_params *); |
---|
61 | }; |
---|
62 | |
---|
63 | struct ambapp_config { |
---|
64 | struct ambapp_bus *abus; /* Prescanned AMBA PnP bus */ |
---|
65 | struct ambapp_ops *ops; /* AMBA bus operations */ |
---|
66 | struct drvmgr_map_entry *maps_up; /* Bus memory map up-stream towards CPU */ |
---|
67 | struct drvmgr_map_entry *maps_down; /* Bus memory map down-stream towards HW */ |
---|
68 | struct drvmgr_bus_res *resources; /* Driver Resources */ |
---|
69 | int bus_type; /* Set DRVMGR_BUS_TYPE_AMBAPP_DIST if distributed AMBA Bus */ |
---|
70 | struct drvmgr_func *funcs; /* Custom functions */ |
---|
71 | }; |
---|
72 | |
---|
73 | /*** Bus operations with READ/WRITE access operations *** |
---|
74 | * |
---|
75 | * The functions are implemented using the standard drvmgr RW interface |
---|
76 | */ |
---|
77 | #define AMBAPP_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_REG) |
---|
78 | #define AMBAPP_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_REG) |
---|
79 | #define AMBAPP_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_REG) |
---|
80 | #define AMBAPP_R64 DRVMGR_RWFUNC(RW_SIZE_8|RW_READ|RW_REG) |
---|
81 | #define AMBAPP_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_REG) |
---|
82 | #define AMBAPP_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_REG) |
---|
83 | #define AMBAPP_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_REG) |
---|
84 | #define AMBAPP_W64 DRVMGR_RWFUNC(RW_SIZE_8|RW_WRITE|RW_REG) |
---|
85 | #define AMBAPP_RMEM DRVMGR_RWFUNC(RW_SIZE_ANY|RW_READ|RW_MEM) |
---|
86 | #define AMBAPP_WMEM DRVMGR_RWFUNC(RW_SIZE_ANY|RW_WRITE|RW_MEM) |
---|
87 | #define AMBAPP_MEMSET DRVMGR_RWFUNC(RW_SIZE_ANY|RW_SET|RW_MEM) |
---|
88 | #define AMBAPP_RW_ARG DRVMGR_RWFUNC(RW_ARG) |
---|
89 | |
---|
90 | /* Register an ambapp bus on-top of a device */ |
---|
91 | extern int ambapp_bus_register( |
---|
92 | struct drvmgr_dev *dev, |
---|
93 | struct ambapp_config *config |
---|
94 | ); |
---|
95 | |
---|
96 | extern void ambapp_bus_freq_register( |
---|
97 | struct drvmgr_dev *dev, |
---|
98 | int amba_interface, |
---|
99 | unsigned int freq_hz); |
---|
100 | |
---|
101 | #ifdef __cplusplus |
---|
102 | } |
---|
103 | #endif |
---|
104 | |
---|
105 | #endif |
---|