[ifxmips]
[openwrt/svn-archive/archive.git] / package / lqtapi / src / mps / mps.h
1 #ifndef __MPS_H__
2 #define __MPS_H__
3
4 #include <linux/platform_device.h>
5 #include <linux/completion.h>
6
7 struct mps_fifo_config
8 {
9 size_t head_addr;
10 size_t tail_addr;
11 size_t base_addr;
12 size_t size_addr;
13
14 size_t base;
15 size_t size;
16 };
17
18 struct mps_fifo {
19 void __iomem *base;
20 void __iomem *head_addr;
21 void __iomem *tail_addr;
22 uint32_t size;
23 };
24
25 struct mps_mailbox {
26 struct mps_fifo upstream;
27 struct mps_fifo downstream;
28 };
29
30 enum mps_boot_config
31 {
32 MPS_BOOT_LEGACY = 1,
33 MPS_BOOT_ENCRYPTED = 2,
34 };
35
36 struct mps {
37 struct resource *res;
38 void __iomem *base;
39
40 struct resource *mbox_res;
41 void __iomem *mbox_base;
42
43 struct resource *cp1_res;
44 void __iomem *cp1_base;
45
46 struct device *dev;
47
48 int irq_ad0;
49 int irq_ad1;
50 int irq_base;
51 };
52
53 void mps_configure_fifo(struct mps *mps, struct mps_fifo *fifo,
54 const struct mps_fifo_config *config);
55
56 void mps_configure_mailbox(struct mps *mps, struct mps_mailbox *mbox,
57 const struct mps_fifo_config *upstream_config,
58 const struct mps_fifo_config *downstream_config);
59
60 void mps_load_firmware(struct mps *mps, const void *data, size_t size,
61 enum mps_boot_config config);
62
63 static inline struct mps *device_to_mps(struct device *dev)
64 {
65 return (struct mps *)dev_get_drvdata(dev);
66 }
67
68 /* fifo */
69 void mps_fifo_init(struct mps_fifo *fifo, void __iomem *data_addr,
70 void __iomem *head_addr, void __iomem *tail_addr, uint32_t size);
71 void mps_fifo_in(struct mps_fifo *fifo, const uint32_t *from, size_t len);
72 void mps_fifo_out(struct mps_fifo *fifo, uint32_t *to, size_t len);
73 uint32_t mps_fifo_peek(struct mps_fifo *fifo);
74 void mps_fifo_reset(struct mps_fifo *fifo);
75 size_t mps_fifo_len(struct mps_fifo *fifo);
76
77 /* Mailbox */
78 int mps_mailbox_init(struct mps_mailbox *mbox, const char *name, int irq);
79 int mps_mailbox_command_read(struct mps_mailbox *mbox, uint32_t cmd,
80 uint32_t *result);
81 int mps_mailbox_command_write(struct mps_mailbox *mbox, uint32_t cmd,
82 const uint32_t *data);
83
84
85 #endif