ssp.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * ssp.h
  3. *
  4. * Copyright (C) 2003 Russell King, All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This driver supports the following PXA CPU/SSP ports:-
  11. *
  12. * PXA250 SSP
  13. * PXA255 SSP, NSSP
  14. * PXA26x SSP, NSSP, ASSP
  15. * PXA27x SSP1, SSP2, SSP3
  16. * PXA3xx SSP1, SSP2, SSP3, SSP4
  17. */
  18. #ifndef __ASM_ARCH_SSP_H
  19. #define __ASM_ARCH_SSP_H
  20. #include <linux/list.h>
  21. #include <linux/io.h>
  22. enum pxa_ssp_type {
  23. SSP_UNDEFINED = 0,
  24. PXA25x_SSP, /* pxa 210, 250, 255, 26x */
  25. PXA25x_NSSP, /* pxa 255, 26x (including ASSP) */
  26. PXA27x_SSP,
  27. };
  28. struct ssp_device {
  29. struct platform_device *pdev;
  30. struct list_head node;
  31. struct clk *clk;
  32. void __iomem *mmio_base;
  33. unsigned long phys_base;
  34. const char *label;
  35. int port_id;
  36. int type;
  37. int use_count;
  38. int irq;
  39. int drcmr_rx;
  40. int drcmr_tx;
  41. };
  42. #ifdef CONFIG_PXA_SSP_LEGACY
  43. /*
  44. * SSP initialisation flags
  45. */
  46. #define SSP_NO_IRQ 0x1 /* don't register an irq handler in SSP driver */
  47. struct ssp_state {
  48. u32 cr0;
  49. u32 cr1;
  50. u32 to;
  51. u32 psp;
  52. };
  53. struct ssp_dev {
  54. struct ssp_device *ssp;
  55. u32 port;
  56. u32 mode;
  57. u32 flags;
  58. u32 psp_flags;
  59. u32 speed;
  60. int irq;
  61. };
  62. int ssp_write_word(struct ssp_dev *dev, u32 data);
  63. int ssp_read_word(struct ssp_dev *dev, u32 *data);
  64. int ssp_flush(struct ssp_dev *dev);
  65. void ssp_enable(struct ssp_dev *dev);
  66. void ssp_disable(struct ssp_dev *dev);
  67. void ssp_save_state(struct ssp_dev *dev, struct ssp_state *ssp);
  68. void ssp_restore_state(struct ssp_dev *dev, struct ssp_state *ssp);
  69. int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags);
  70. int ssp_config(struct ssp_dev *dev, u32 mode, u32 flags, u32 psp_flags, u32 speed);
  71. void ssp_exit(struct ssp_dev *dev);
  72. #endif /* CONFIG_PXA_SSP_LEGACY */
  73. /**
  74. * ssp_write_reg - Write to a SSP register
  75. *
  76. * @dev: SSP device to access
  77. * @reg: Register to write to
  78. * @val: Value to be written.
  79. */
  80. static inline void ssp_write_reg(struct ssp_device *dev, u32 reg, u32 val)
  81. {
  82. __raw_writel(val, dev->mmio_base + reg);
  83. }
  84. /**
  85. * ssp_read_reg - Read from a SSP register
  86. *
  87. * @dev: SSP device to access
  88. * @reg: Register to read from
  89. */
  90. static inline u32 ssp_read_reg(struct ssp_device *dev, u32 reg)
  91. {
  92. return __raw_readl(dev->mmio_base + reg);
  93. }
  94. struct ssp_device *ssp_request(int port, const char *label);
  95. void ssp_free(struct ssp_device *);
  96. #endif /* __ASM_ARCH_SSP_H */