pwm.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Pulse Width Modulation Memory Map
  3. *
  4. * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
  5. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __ATA_H__
  10. #define __ATA_H__
  11. /* Pulse Width Modulation (PWM) */
  12. typedef struct pwm_ctrl {
  13. #ifdef CONFIG_M5272
  14. u8 cr0;
  15. u8 res1[3];
  16. u8 cr1;
  17. u8 res2[3];
  18. u8 cr2;
  19. u8 res3[7];
  20. u8 pwr0;
  21. u8 res4[3];
  22. u8 pwr1;
  23. u8 res5[3];
  24. u8 pwr2;
  25. u8 res6[7];
  26. #else
  27. u8 en; /* 0x00 PWM Enable */
  28. u8 pol; /* 0x01 Polarity */
  29. u8 clk; /* 0x02 Clock Select */
  30. u8 prclk; /* 0x03 Prescale Clock Select */
  31. u8 cae; /* 0x04 Center Align Enable */
  32. u8 ctl; /* 0x05 Control */
  33. u16 res1; /* 0x06 - 0x07 */
  34. u8 scla; /* 0x08 Scale A */
  35. u8 sclb; /* 0x09 Scale B */
  36. u16 res2; /* 0x0A - 0x0B */
  37. #ifdef CONFIG_M5275
  38. u8 cnt[4]; /* 0x0C Channel n Counter */
  39. u16 res3; /* 0x10 - 0x11 */
  40. u8 per[4]; /* 0x14 Channel n Period */
  41. u16 res4; /* 0x16 - 0x17 */
  42. u8 dty[4]; /* 0x18 Channel n Duty */
  43. #else
  44. u8 cnt[8]; /* 0x0C Channel n Counter */
  45. u8 per[8]; /* 0x14 Channel n Period */
  46. u8 dty[8]; /* 0x1C Channel n Duty */
  47. u8 sdn; /* 0x24 Shutdown */
  48. u8 res3[3]; /* 0x25 - 0x27 */
  49. #endif /* CONFIG_M5275 */
  50. #endif /* CONFIG_M5272 */
  51. } pwm_t;
  52. #ifdef CONFIG_M5272
  53. #define PWM_CR_EN (0x80)
  54. #define PWM_CR_FRC1 (0x40)
  55. #define PWM_CR_LVL (0x20)
  56. #define PWM_CR_CLKSEL(x) ((x) & 0x0F)
  57. #define PWM_CR_CLKSEL_MASK (0xF0)
  58. #else
  59. #define PWM_EN_PWMEn(x) (1 << ((x) & 0x07))
  60. #define PWM_EN_PWMEn_MASK (0xF0)
  61. #define PWM_POL_PPOLn(x) (1 << ((x) & 0x07))
  62. #define PWM_POL_PPOLn_MASK (0xF0)
  63. #define PWM_CLK_PCLKn(x) (1 << ((x) & 0x07))
  64. #define PWM_CLK_PCLKn_MASK (0xF0)
  65. #define PWM_PRCLK_PCKB(x) (((x) & 0x07) << 4)
  66. #define PWM_PRCLK_PCKB_MASK (0x8F)
  67. #define PWM_PRCLK_PCKA(x) ((x) & 0x07)
  68. #define PWM_PRCLK_PCKA_MASK (0xF8)
  69. #define PWM_CLK_PCLKn(x) (1 << ((x) & 0x07))
  70. #define PWM_CLK_PCLKn_MASK (0xF0)
  71. #define PWM_CTL_CON67 (0x80)
  72. #define PWM_CTL_CON45 (0x40)
  73. #define PWM_CTL_CON23 (0x20)
  74. #define PWM_CTL_CON01 (0x10)
  75. #define PWM_CTL_PSWAR (0x08)
  76. #define PWM_CTL_PFRZ (0x04)
  77. #define PWM_SDN_IF (0x80)
  78. #define PWM_SDN_IE (0x40)
  79. #define PWM_SDN_RESTART (0x20)
  80. #define PWM_SDN_LVL (0x10)
  81. #define PWM_SDN_PWM7IN (0x04)
  82. #define PWM_SDN_PWM7IL (0x02)
  83. #define PWM_SDN_SDNEN (0x01)
  84. #endif /* CONFIG_M5272 */
  85. #endif /* __ATA_H__ */