aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/amba/bus.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/amba/bus.h')
-rw-r--r--include/linux/amba/bus.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index b0c174012436..fcbbe71a3cc1 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -18,8 +18,10 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/resource.h> 20#include <linux/resource.h>
21#include <linux/regulator/consumer.h>
21 22
22#define AMBA_NR_IRQS 2 23#define AMBA_NR_IRQS 2
24#define AMBA_CID 0xb105f00d
23 25
24struct clk; 26struct clk;
25 27
@@ -27,6 +29,7 @@ struct amba_device {
27 struct device dev; 29 struct device dev;
28 struct resource res; 30 struct resource res;
29 struct clk *pclk; 31 struct clk *pclk;
32 struct regulator *vcore;
30 u64 dma_mask; 33 u64 dma_mask;
31 unsigned int periphid; 34 unsigned int periphid;
32 unsigned int irq[AMBA_NR_IRQS]; 35 unsigned int irq[AMBA_NR_IRQS];
@@ -40,12 +43,12 @@ struct amba_id {
40 43
41struct amba_driver { 44struct amba_driver {
42 struct device_driver drv; 45 struct device_driver drv;
43 int (*probe)(struct amba_device *, struct amba_id *); 46 int (*probe)(struct amba_device *, const struct amba_id *);
44 int (*remove)(struct amba_device *); 47 int (*remove)(struct amba_device *);
45 void (*shutdown)(struct amba_device *); 48 void (*shutdown)(struct amba_device *);
46 int (*suspend)(struct amba_device *, pm_message_t); 49 int (*suspend)(struct amba_device *, pm_message_t);
47 int (*resume)(struct amba_device *); 50 int (*resume)(struct amba_device *);
48 struct amba_id *id_table; 51 const struct amba_id *id_table;
49}; 52};
50 53
51enum amba_vendor { 54enum amba_vendor {
@@ -53,6 +56,10 @@ enum amba_vendor {
53 AMBA_VENDOR_ST = 0x80, 56 AMBA_VENDOR_ST = 0x80,
54}; 57};
55 58
59extern struct bus_type amba_bustype;
60
61#define to_amba_device(d) container_of(d, struct amba_device, dev)
62
56#define amba_get_drvdata(d) dev_get_drvdata(&d->dev) 63#define amba_get_drvdata(d) dev_get_drvdata(&d->dev)
57#define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p) 64#define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p)
58 65
@@ -70,9 +77,21 @@ void amba_release_regions(struct amba_device *);
70#define amba_pclk_disable(d) \ 77#define amba_pclk_disable(d) \
71 do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0) 78 do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0)
72 79
73#define amba_config(d) (((d)->periphid >> 24) & 0xff) 80#define amba_vcore_enable(d) \
74#define amba_rev(d) (((d)->periphid >> 20) & 0x0f) 81 (IS_ERR((d)->vcore) ? 0 : regulator_enable((d)->vcore))
75#define amba_manf(d) (((d)->periphid >> 12) & 0xff) 82
76#define amba_part(d) ((d)->periphid & 0xfff) 83#define amba_vcore_disable(d) \
84 do { if (!IS_ERR((d)->vcore)) regulator_disable((d)->vcore); } while (0)
85
86/* Some drivers don't use the struct amba_device */
87#define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
88#define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)
89#define AMBA_MANF_BITS(a) (((a) >> 12) & 0xff)
90#define AMBA_PART_BITS(a) ((a) & 0xfff)
91
92#define amba_config(d) AMBA_CONFIG_BITS((d)->periphid)
93#define amba_rev(d) AMBA_REV_BITS((d)->periphid)
94#define amba_manf(d) AMBA_MANF_BITS((d)->periphid)
95#define amba_part(d) AMBA_PART_BITS((d)->periphid)
77 96
78#endif 97#endif