| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2010-02-20 09:41:30 +01:00
										 |  |  |  *  linux/include/amba/bus.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  This device type deals with ARM PrimeCells and anything else that | 
					
						
							|  |  |  |  *  presents a proper CID (0xB105F00D) at the end of the I/O register | 
					
						
							|  |  |  |  *  region or that is derived from a PrimeCell. | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  *  Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License version 2 as | 
					
						
							|  |  |  |  * published by the Free Software Foundation. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifndef ASMARM_AMBA_H
 | 
					
						
							|  |  |  | #define ASMARM_AMBA_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-15 10:47:14 +01:00
										 |  |  | #include <linux/clk.h>
 | 
					
						
							| 
									
										
										
										
											2010-03-29 05:28:32 +01:00
										 |  |  | #include <linux/device.h>
 | 
					
						
							| 
									
										
										
										
											2011-10-05 14:40:59 +01:00
										 |  |  | #include <linux/mod_devicetable.h>
 | 
					
						
							| 
									
										
										
										
											2010-07-15 10:47:14 +01:00
										 |  |  | #include <linux/err.h>
 | 
					
						
							| 
									
										
										
										
											2010-03-29 05:28:32 +01:00
										 |  |  | #include <linux/resource.h>
 | 
					
						
							| 
									
										
										
										
											2010-11-04 13:06:59 +01:00
										 |  |  | #include <linux/regulator/consumer.h>
 | 
					
						
							| 
									
										
										
										
											2010-03-29 05:28:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-29 16:02:00 +01:00
										 |  |  | #define AMBA_NR_IRQS	9
 | 
					
						
							| 
									
										
										
										
											2010-09-07 22:43:19 +01:00
										 |  |  | #define AMBA_CID	0xb105f00d
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-15 10:47:14 +01:00
										 |  |  | struct clk; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | struct amba_device { | 
					
						
							|  |  |  | 	struct device		dev; | 
					
						
							|  |  |  | 	struct resource		res; | 
					
						
							| 
									
										
										
										
											2010-07-15 10:47:14 +01:00
										 |  |  | 	struct clk		*pclk; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	unsigned int		periphid; | 
					
						
							|  |  |  | 	unsigned int		irq[AMBA_NR_IRQS]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct amba_driver { | 
					
						
							|  |  |  | 	struct device_driver	drv; | 
					
						
							| 
									
										
										
										
											2011-02-19 15:55:00 +00:00
										 |  |  | 	int			(*probe)(struct amba_device *, const struct amba_id *); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	int			(*remove)(struct amba_device *); | 
					
						
							|  |  |  | 	void			(*shutdown)(struct amba_device *); | 
					
						
							|  |  |  | 	int			(*suspend)(struct amba_device *, pm_message_t); | 
					
						
							|  |  |  | 	int			(*resume)(struct amba_device *); | 
					
						
							| 
									
										
										
										
											2011-02-19 15:55:48 +00:00
										 |  |  | 	const struct amba_id	*id_table; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-04 01:01:02 +01:00
										 |  |  | enum amba_vendor { | 
					
						
							|  |  |  | 	AMBA_VENDOR_ARM = 0x41, | 
					
						
							|  |  |  | 	AMBA_VENDOR_ST = 0x80, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-12 15:58:25 +01:00
										 |  |  | extern struct bus_type amba_bustype; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-23 04:33:17 +01:00
										 |  |  | #define to_amba_device(d)	container_of(d, struct amba_device, dev)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #define amba_get_drvdata(d)	dev_get_drvdata(&d->dev)
 | 
					
						
							|  |  |  | #define amba_set_drvdata(d,p)	dev_set_drvdata(&d->dev, p)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int amba_driver_register(struct amba_driver *); | 
					
						
							|  |  |  | void amba_driver_unregister(struct amba_driver *); | 
					
						
							| 
									
										
										
										
											2011-12-18 11:07:47 +00:00
										 |  |  | struct amba_device *amba_device_alloc(const char *, resource_size_t, size_t); | 
					
						
							|  |  |  | void amba_device_put(struct amba_device *); | 
					
						
							|  |  |  | int amba_device_add(struct amba_device *, struct resource *); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | int amba_device_register(struct amba_device *, struct resource *); | 
					
						
							| 
									
										
										
										
											2012-04-03 11:58:42 +01:00
										 |  |  | struct amba_device *amba_apb_device_add(struct device *parent, const char *name, | 
					
						
							|  |  |  | 					resource_size_t base, size_t size, | 
					
						
							|  |  |  | 					int irq1, int irq2, void *pdata, | 
					
						
							|  |  |  | 					unsigned int periphid); | 
					
						
							|  |  |  | struct amba_device *amba_ahb_device_add(struct device *parent, const char *name, | 
					
						
							|  |  |  | 					resource_size_t base, size_t size, | 
					
						
							|  |  |  | 					int irq1, int irq2, void *pdata, | 
					
						
							|  |  |  | 					unsigned int periphid); | 
					
						
							| 
									
										
										
										
											2012-11-30 16:30:43 +01:00
										 |  |  | struct amba_device * | 
					
						
							|  |  |  | amba_apb_device_add_res(struct device *parent, const char *name, | 
					
						
							|  |  |  | 			resource_size_t base, size_t size, int irq1, | 
					
						
							|  |  |  | 			int irq2, void *pdata, unsigned int periphid, | 
					
						
							|  |  |  | 			struct resource *resbase); | 
					
						
							|  |  |  | struct amba_device * | 
					
						
							|  |  |  | amba_ahb_device_add_res(struct device *parent, const char *name, | 
					
						
							|  |  |  | 			resource_size_t base, size_t size, int irq1, | 
					
						
							|  |  |  | 			int irq2, void *pdata, unsigned int periphid, | 
					
						
							|  |  |  | 			struct resource *resbase); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | void amba_device_unregister(struct amba_device *); | 
					
						
							|  |  |  | struct amba_device *amba_find_device(const char *, struct device *, unsigned int, unsigned int); | 
					
						
							|  |  |  | int amba_request_regions(struct amba_device *, const char *); | 
					
						
							|  |  |  | void amba_release_regions(struct amba_device *); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-15 10:47:14 +01:00
										 |  |  | #define amba_pclk_enable(d)	\
 | 
					
						
							|  |  |  | 	(IS_ERR((d)->pclk) ? 0 : clk_enable((d)->pclk)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define amba_pclk_disable(d)	\
 | 
					
						
							|  |  |  | 	do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-07 22:43:19 +01:00
										 |  |  | /* Some drivers don't use the struct amba_device */ | 
					
						
							|  |  |  | #define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
 | 
					
						
							|  |  |  | #define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)
 | 
					
						
							|  |  |  | #define AMBA_MANF_BITS(a) (((a) >> 12) & 0xff)
 | 
					
						
							|  |  |  | #define AMBA_PART_BITS(a) ((a) & 0xfff)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define amba_config(d)	AMBA_CONFIG_BITS((d)->periphid)
 | 
					
						
							|  |  |  | #define amba_rev(d)	AMBA_REV_BITS((d)->periphid)
 | 
					
						
							|  |  |  | #define amba_manf(d)	AMBA_MANF_BITS((d)->periphid)
 | 
					
						
							|  |  |  | #define amba_part(d)	AMBA_PART_BITS((d)->periphid)
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-18 12:06:25 +00:00
										 |  |  | #define __AMBA_DEV(busid, data, mask)				\
 | 
					
						
							|  |  |  | 	{							\ | 
					
						
							|  |  |  | 		.coherent_dma_mask = mask,			\ | 
					
						
							|  |  |  | 		.init_name = busid,				\ | 
					
						
							|  |  |  | 		.platform_data = data,				\ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * APB devices do not themselves have the ability to address memory, | 
					
						
							|  |  |  |  * so DMA masks should be zero (much like USB peripheral devices.) | 
					
						
							|  |  |  |  * The DMA controller DMA masks should be used instead (much like | 
					
						
							|  |  |  |  * USB host controllers in conventional PCs.) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define AMBA_APB_DEVICE(name, busid, id, base, irqs, data)	\
 | 
					
						
							|  |  |  | struct amba_device name##_device = {				\ | 
					
						
							|  |  |  | 	.dev = __AMBA_DEV(busid, data, 0),			\ | 
					
						
							|  |  |  | 	.res = DEFINE_RES_MEM(base, SZ_4K),			\ | 
					
						
							|  |  |  | 	.irq = irqs,						\ | 
					
						
							|  |  |  | 	.periphid = id,						\ | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * AHB devices are DMA capable, so set their DMA masks | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define AMBA_AHB_DEVICE(name, busid, id, base, irqs, data)	\
 | 
					
						
							|  |  |  | struct amba_device name##_device = {				\ | 
					
						
							|  |  |  | 	.dev = __AMBA_DEV(busid, data, ~0ULL),			\ | 
					
						
							|  |  |  | 	.res = DEFINE_RES_MEM(base, SZ_4K),			\ | 
					
						
							|  |  |  | 	.irq = irqs,						\ | 
					
						
							|  |  |  | 	.periphid = id,						\ | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-15 10:40:38 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * module_amba_driver() - Helper macro for drivers that don't do anything | 
					
						
							|  |  |  |  * special in module init/exit.  This eliminates a lot of boilerplate.  Each | 
					
						
							|  |  |  |  * module may only use this macro once, and calling it replaces module_init() | 
					
						
							|  |  |  |  * and module_exit() | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define module_amba_driver(__amba_drv) \
 | 
					
						
							|  |  |  | 	module_driver(__amba_drv, amba_driver_register, amba_driver_unregister) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 |