smsc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * SMSC ECE1099
  3. *
  4. * Copyright 2012 Texas Instruments Inc.
  5. *
  6. * Author: Sourav Poddar <sourav.poddar@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. */
  14. #ifndef __LINUX_MFD_SMSC_H
  15. #define __LINUX_MFD_SMSC_H
  16. #include <linux/regmap.h>
  17. #define SMSC_ID_ECE1099 1
  18. #define SMSC_NUM_CLIENTS 2
  19. #define SMSC_BASE_ADDR 0x38
  20. #define OMAP_GPIO_SMSC_IRQ 151
  21. #define SMSC_MAXGPIO 32
  22. #define SMSC_BANK(offs) ((offs) >> 3)
  23. #define SMSC_BIT(offs) (1u << ((offs) & 0x7))
  24. struct smsc {
  25. struct device *dev;
  26. struct i2c_client *i2c_clients[SMSC_NUM_CLIENTS];
  27. struct regmap *regmap;
  28. int clk;
  29. /* Stored chip id */
  30. int id;
  31. };
  32. struct smsc_gpio;
  33. struct smsc_keypad;
  34. static inline int smsc_read(struct device *child, unsigned int reg,
  35. unsigned int *dest)
  36. {
  37. struct smsc *smsc = dev_get_drvdata(child->parent);
  38. return regmap_read(smsc->regmap, reg, dest);
  39. }
  40. static inline int smsc_write(struct device *child, unsigned int reg,
  41. unsigned int value)
  42. {
  43. struct smsc *smsc = dev_get_drvdata(child->parent);
  44. return regmap_write(smsc->regmap, reg, value);
  45. }
  46. /* Registers for SMSC */
  47. #define SMSC_RESET 0xF5
  48. #define SMSC_GRP_INT 0xF9
  49. #define SMSC_CLK_CTRL 0xFA
  50. #define SMSC_WKUP_CTRL 0xFB
  51. #define SMSC_DEV_ID 0xFC
  52. #define SMSC_DEV_REV 0xFD
  53. #define SMSC_VEN_ID_L 0xFE
  54. #define SMSC_VEN_ID_H 0xFF
  55. /* CLK VALUE */
  56. #define SMSC_CLK_VALUE 0x13
  57. /* Registers for function GPIO INPUT */
  58. #define SMSC_GPIO_DATA_IN_START 0x00
  59. /* Registers for function GPIO OUPUT */
  60. #define SMSC_GPIO_DATA_OUT_START 0x05
  61. /* Definitions for SMSC GPIO CONFIGURATION REGISTER*/
  62. #define SMSC_GPIO_INPUT_LOW 0x01
  63. #define SMSC_GPIO_INPUT_RISING 0x09
  64. #define SMSC_GPIO_INPUT_FALLING 0x11
  65. #define SMSC_GPIO_INPUT_BOTH_EDGE 0x19
  66. #define SMSC_GPIO_OUTPUT_PP 0x21
  67. #define SMSC_GPIO_OUTPUT_OP 0x31
  68. #define GRP_INT_STAT 0xf9
  69. #define SMSC_GPI_INT 0x0f
  70. #define SMSC_CFG_START 0x0A
  71. /* Registers for SMSC GPIO INTERRUPT STATUS REGISTER*/
  72. #define SMSC_GPIO_INT_STAT_START 0x32
  73. /* Registers for SMSC GPIO INTERRUPT MASK REGISTER*/
  74. #define SMSC_GPIO_INT_MASK_START 0x37
  75. /* Registers for SMSC function KEYPAD*/
  76. #define SMSC_KP_OUT 0x40
  77. #define SMSC_KP_IN 0x41
  78. #define SMSC_KP_INT_STAT 0x42
  79. #define SMSC_KP_INT_MASK 0x43
  80. /* Definitions for keypad */
  81. #define SMSC_KP_KSO 0x70
  82. #define SMSC_KP_KSI 0x51
  83. #define SMSC_KSO_ALL_LOW 0x20
  84. #define SMSC_KP_SET_LOW_PWR 0x0B
  85. #define SMSC_KP_SET_HIGH 0xFF
  86. #define SMSC_KSO_EVAL 0x00
  87. #endif /* __LINUX_MFD_SMSC_H */