i2sbus.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * i2sbus driver -- private definitions
  3. *
  4. * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
  5. *
  6. * GPL v2, can be found in COPYING.
  7. */
  8. #ifndef __I2SBUS_H
  9. #define __I2SBUS_H
  10. #include <linux/interrupt.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/mutex.h>
  13. #include <linux/completion.h>
  14. #include <sound/pcm.h>
  15. #include <asm/prom.h>
  16. #include <asm/pmac_feature.h>
  17. #include <asm/dbdma.h>
  18. #include "interface.h"
  19. #include "../soundbus.h"
  20. struct i2sbus_control {
  21. struct list_head list;
  22. struct macio_chip *macio;
  23. };
  24. #define MAX_DBDMA_COMMANDS 32
  25. struct dbdma_command_mem {
  26. dma_addr_t bus_addr;
  27. dma_addr_t bus_cmd_start;
  28. struct dbdma_cmd *cmds;
  29. void *space;
  30. int size;
  31. u32 running:1;
  32. u32 stopping:1;
  33. };
  34. struct pcm_info {
  35. u32 created:1, /* has this direction been created with alsa? */
  36. active:1; /* is this stream active? */
  37. /* runtime information */
  38. struct snd_pcm_substream *substream;
  39. int current_period;
  40. u32 frame_count;
  41. struct dbdma_command_mem dbdma_ring;
  42. volatile struct dbdma_regs __iomem *dbdma;
  43. struct completion *stop_completion;
  44. };
  45. enum {
  46. aoa_resource_i2smmio = 0,
  47. aoa_resource_txdbdma,
  48. aoa_resource_rxdbdma,
  49. };
  50. struct i2sbus_dev {
  51. struct soundbus_dev sound;
  52. struct macio_dev *macio;
  53. struct i2sbus_control *control;
  54. volatile struct i2s_interface_regs __iomem *intfregs;
  55. struct resource resources[3];
  56. struct resource *allocated_resource[3];
  57. int interrupts[3];
  58. char rnames[3][32];
  59. /* info about currently active substreams */
  60. struct pcm_info out, in;
  61. snd_pcm_format_t format;
  62. unsigned int rate;
  63. /* list for a single controller */
  64. struct list_head item;
  65. /* number of bus on controller */
  66. int bus_number;
  67. /* for use by control layer */
  68. struct pmf_function *enable,
  69. *cell_enable,
  70. *cell_disable,
  71. *clock_enable,
  72. *clock_disable;
  73. /* locks */
  74. /* spinlock for low-level interrupt locking */
  75. spinlock_t low_lock;
  76. /* mutex for high-level consistency */
  77. struct mutex lock;
  78. };
  79. #define soundbus_dev_to_i2sbus_dev(sdev) \
  80. container_of(sdev, struct i2sbus_dev, sound)
  81. /* pcm specific functions */
  82. extern int
  83. i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
  84. struct codec_info *ci, void *data);
  85. extern void
  86. i2sbus_detach_codec(struct soundbus_dev *dev, void *data);
  87. extern irqreturn_t
  88. i2sbus_tx_intr(int irq, void *devid);
  89. extern irqreturn_t
  90. i2sbus_rx_intr(int irq, void *devid);
  91. extern void i2sbus_wait_for_stop_both(struct i2sbus_dev *i2sdev);
  92. extern void i2sbus_pcm_prepare_both(struct i2sbus_dev *i2sdev);
  93. /* control specific functions */
  94. extern int i2sbus_control_init(struct macio_dev* dev,
  95. struct i2sbus_control **c);
  96. extern void i2sbus_control_destroy(struct i2sbus_control *c);
  97. extern int i2sbus_control_add_dev(struct i2sbus_control *c,
  98. struct i2sbus_dev *i2sdev);
  99. extern void i2sbus_control_remove_dev(struct i2sbus_control *c,
  100. struct i2sbus_dev *i2sdev);
  101. extern int i2sbus_control_enable(struct i2sbus_control *c,
  102. struct i2sbus_dev *i2sdev);
  103. extern int i2sbus_control_cell(struct i2sbus_control *c,
  104. struct i2sbus_dev *i2sdev,
  105. int enable);
  106. extern int i2sbus_control_clock(struct i2sbus_control *c,
  107. struct i2sbus_dev *i2sdev,
  108. int enable);
  109. #endif /* __I2SBUS_H */