0040-soc-mediatek-PMIC-wrap-add-mt6323-slave-support.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 4418ba9a0bb105f00259d10ceb16f9e27199e9b0 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Wed, 20 Jan 2016 11:40:43 +0100
  4. Subject: [PATCH 040/102] soc: mediatek: PMIC wrap: add mt6323 slave support
  5. Add support for MT6323 slaves. This PMIC can be found on MT2701 and MT7623
  6. EVB. The only function that we need to touch is pwrap_init_cipher().
  7. Signed-off-by: John Crispin <blogic@openwrt.org>
  8. ---
  9. drivers/soc/mediatek/mtk-pmic-wrap.c | 43 ++++++++++++++++++++++++++++++++++
  10. 1 file changed, 43 insertions(+)
  11. --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
  12. +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
  13. @@ -93,6 +93,27 @@ enum dew_regs {
  14. PWRAP_DEW_EVENT_TEST,
  15. PWRAP_DEW_CIPHER_LOAD,
  16. PWRAP_DEW_CIPHER_START,
  17. +
  18. + /* MT6323 only regs */
  19. + PWRAP_DEW_CIPHER_EN,
  20. + PWRAP_DEW_RDDMY_NO,
  21. +};
  22. +
  23. +static const u32 mt6323_regs[] = {
  24. + [PWRAP_DEW_BASE] = 0x0000,
  25. + [PWRAP_DEW_DIO_EN] = 0x018a,
  26. + [PWRAP_DEW_READ_TEST] = 0x018c,
  27. + [PWRAP_DEW_WRITE_TEST] = 0x018e,
  28. + [PWRAP_DEW_CRC_EN] = 0x0192,
  29. + [PWRAP_DEW_CRC_VAL] = 0x0194,
  30. + [PWRAP_DEW_MON_GRP_SEL] = 0x0196,
  31. + [PWRAP_DEW_CIPHER_KEY_SEL] = 0x0198,
  32. + [PWRAP_DEW_CIPHER_IV_SEL] = 0x019a,
  33. + [PWRAP_DEW_CIPHER_EN] = 0x019c,
  34. + [PWRAP_DEW_CIPHER_RDY] = 0x019e,
  35. + [PWRAP_DEW_CIPHER_MODE] = 0x01a0,
  36. + [PWRAP_DEW_CIPHER_SWRST] = 0x01a2,
  37. + [PWRAP_DEW_RDDMY_NO] = 0x01a4,
  38. };
  39. static const u32 mt6397_regs[] = {
  40. @@ -371,6 +392,7 @@ static int mt8135_regs[] = {
  41. };
  42. enum pmic_type {
  43. + PMIC_MT6323,
  44. PMIC_MT6397,
  45. };
  46. @@ -661,6 +683,19 @@ static int pwrap_init_cipher(struct pmic
  47. pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD], 0x1);
  48. pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START], 0x1);
  49. + switch (wrp->slave->type) {
  50. + case PMIC_MT6397:
  51. + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD],
  52. + 0x1);
  53. + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START],
  54. + 0x1);
  55. + break;
  56. + case PMIC_MT6323:
  57. + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN],
  58. + 0x1);
  59. + break;
  60. + }
  61. +
  62. /* wait for cipher data ready@AP */
  63. ret = pwrap_wait_for_state(wrp, pwrap_is_cipher_ready);
  64. if (ret) {
  65. @@ -858,6 +893,11 @@ static const struct regmap_config pwrap_
  66. .max_register = 0xffff,
  67. };
  68. +static const struct pwrap_slv_type pmic_mt6323 = {
  69. + .dew_regs = mt6323_regs,
  70. + .type = PMIC_MT6323,
  71. +};
  72. +
  73. static const struct pwrap_slv_type pmic_mt6397 = {
  74. .dew_regs = mt6397_regs,
  75. .type = PMIC_MT6397,
  76. @@ -865,6 +905,9 @@ static const struct pwrap_slv_type pmic_
  77. static const struct of_device_id of_slave_match_tbl[] = {
  78. {
  79. + .compatible = "mediatek,mt6323",
  80. + .data = &pmic_mt6323,
  81. + }, {
  82. .compatible = "mediatek,mt6397",
  83. .data = &pmic_mt6397,
  84. }, {