bus.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * linux/include/amba/bus.h
  3. *
  4. * This device type deals with ARM PrimeCells and anything else that
  5. * presents a proper CID (0xB105F00D) at the end of the I/O register
  6. * region or that is derived from a PrimeCell.
  7. *
  8. * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef ASMARM_AMBA_H
  15. #define ASMARM_AMBA_H
  16. #include <linux/clk.h>
  17. #include <linux/device.h>
  18. #include <linux/mod_devicetable.h>
  19. #include <linux/err.h>
  20. #include <linux/resource.h>
  21. #include <linux/regulator/consumer.h>
  22. #define AMBA_NR_IRQS 2
  23. #define AMBA_CID 0xb105f00d
  24. struct clk;
  25. struct amba_device {
  26. struct device dev;
  27. struct resource res;
  28. struct clk *pclk;
  29. struct regulator *vcore;
  30. u64 dma_mask;
  31. unsigned int periphid;
  32. unsigned int irq[AMBA_NR_IRQS];
  33. };
  34. struct amba_driver {
  35. struct device_driver drv;
  36. int (*probe)(struct amba_device *, const struct amba_id *);
  37. int (*remove)(struct amba_device *);
  38. void (*shutdown)(struct amba_device *);
  39. int (*suspend)(struct amba_device *, pm_message_t);
  40. int (*resume)(struct amba_device *);
  41. const struct amba_id *id_table;
  42. };
  43. enum amba_vendor {
  44. AMBA_VENDOR_ARM = 0x41,
  45. AMBA_VENDOR_ST = 0x80,
  46. };
  47. extern struct bus_type amba_bustype;
  48. #define to_amba_device(d) container_of(d, struct amba_device, dev)
  49. #define amba_get_drvdata(d) dev_get_drvdata(&d->dev)
  50. #define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p)
  51. int amba_driver_register(struct amba_driver *);
  52. void amba_driver_unregister(struct amba_driver *);
  53. struct amba_device *amba_device_alloc(const char *, resource_size_t, size_t);
  54. void amba_device_put(struct amba_device *);
  55. int amba_device_add(struct amba_device *, struct resource *);
  56. int amba_device_register(struct amba_device *, struct resource *);
  57. void amba_device_unregister(struct amba_device *);
  58. struct amba_device *amba_find_device(const char *, struct device *, unsigned int, unsigned int);
  59. int amba_request_regions(struct amba_device *, const char *);
  60. void amba_release_regions(struct amba_device *);
  61. #define amba_pclk_enable(d) \
  62. (IS_ERR((d)->pclk) ? 0 : clk_enable((d)->pclk))
  63. #define amba_pclk_disable(d) \
  64. do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0)
  65. #define amba_vcore_enable(d) \
  66. (IS_ERR((d)->vcore) ? 0 : regulator_enable((d)->vcore))
  67. #define amba_vcore_disable(d) \
  68. do { if (!IS_ERR((d)->vcore)) regulator_disable((d)->vcore); } while (0)
  69. /* Some drivers don't use the struct amba_device */
  70. #define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
  71. #define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)
  72. #define AMBA_MANF_BITS(a) (((a) >> 12) & 0xff)
  73. #define AMBA_PART_BITS(a) ((a) & 0xfff)
  74. #define amba_config(d) AMBA_CONFIG_BITS((d)->periphid)
  75. #define amba_rev(d) AMBA_REV_BITS((d)->periphid)
  76. #define amba_manf(d) AMBA_MANF_BITS((d)->periphid)
  77. #define amba_part(d) AMBA_PART_BITS((d)->periphid)
  78. #endif