devices-common.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
  5. * License terms: GNU General Public License (GPL), version 2.
  6. */
  7. #ifndef __DEVICES_COMMON_H
  8. #define __DEVICES_COMMON_H
  9. #include <linux/platform_device.h>
  10. #include <linux/dma-mapping.h>
  11. #include <linux/sys_soc.h>
  12. #include <linux/amba/bus.h>
  13. #include <linux/platform_data/i2c-nomadik.h>
  14. struct spi_master_cntlr;
  15. static inline struct amba_device *
  16. dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
  17. int irq, struct spi_master_cntlr *pdata,
  18. u32 periphid)
  19. {
  20. return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
  21. pdata, periphid);
  22. }
  23. struct mmci_platform_data;
  24. static inline struct amba_device *
  25. dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
  26. int irq, struct mmci_platform_data *pdata, u32 periphid)
  27. {
  28. return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
  29. pdata, periphid);
  30. }
  31. struct amba_pl011_data;
  32. static inline struct amba_device *
  33. dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
  34. int irq, struct amba_pl011_data *pdata)
  35. {
  36. return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, pdata, 0);
  37. }
  38. struct nmk_i2c_controller;
  39. static inline struct amba_device *
  40. dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
  41. struct nmk_i2c_controller *data)
  42. {
  43. /* Conjure a name similar to what the platform device used to have */
  44. char name[16];
  45. snprintf(name, sizeof(name), "nmk-i2c.%d", id);
  46. return amba_apb_device_add(parent, name, base, SZ_4K, irq, 0, data, 0);
  47. }
  48. static inline struct amba_device *
  49. dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
  50. {
  51. return amba_apb_device_add(parent, "rtc-pl031", base, SZ_4K, irq,
  52. 0, NULL, 0);
  53. }
  54. struct hash_platform_data;
  55. static inline struct platform_device *
  56. dbx500_add_hash1(struct device *parent, int id, resource_size_t base,
  57. struct hash_platform_data *pdata)
  58. {
  59. struct resource res[] = {
  60. DEFINE_RES_MEM(base, SZ_4K),
  61. };
  62. struct platform_device_info pdevinfo = {
  63. .parent = parent,
  64. .name = "hash1",
  65. .id = id,
  66. .res = res,
  67. .num_res = ARRAY_SIZE(res),
  68. .data = pdata,
  69. .size_data = sizeof(*pdata),
  70. .dma_mask = DMA_BIT_MASK(32),
  71. };
  72. return platform_device_register_full(&pdevinfo);
  73. }
  74. struct nmk_gpio_platform_data;
  75. void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
  76. int irq, struct nmk_gpio_platform_data *pdata);
  77. static inline void
  78. dbx500_add_pinctrl(struct device *parent, const char *name,
  79. resource_size_t base)
  80. {
  81. struct resource res[] = {
  82. DEFINE_RES_MEM(base, SZ_8K),
  83. };
  84. struct platform_device_info pdevinfo = {
  85. .parent = parent,
  86. .name = name,
  87. .id = -1,
  88. .res = res,
  89. .num_res = ARRAY_SIZE(res),
  90. };
  91. platform_device_register_full(&pdevinfo);
  92. }
  93. #endif