Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: chipidea: add chipidea revision information

Define ci_get_revision API to know the controller revision
information according to chipidea 1.1a, 2.0a and 2.5a spec.
Besides, add one entry at struct ci_hdrc to indicate revision
information, it can be used for adding different code for
revisions, eg kinds of errata.

Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Chen and committed by
Greg Kroah-Hartman
cb271f3c 655d32e9

+45 -2
+10
drivers/usb/chipidea/bits.h
··· 15 15 16 16 #include <linux/usb/ehci_def.h> 17 17 18 + /* 19 + * ID 20 + * For 1.x revision, bit24 - bit31 are reserved 21 + * For 2.x revision, bit25 - bit28 are 0x2 22 + */ 23 + #define TAG (0x1F << 16) 24 + #define REVISION (0xF << 21) 25 + #define VERSION (0xF << 25) 26 + #define CIVERSION (0x7 << 29) 27 + 18 28 /* HCCPARAMS */ 19 29 #define HCCPARAMS_LEN BIT(17) 20 30
+14
drivers/usb/chipidea/ci.h
··· 106 106 CI_ROLE_END, 107 107 }; 108 108 109 + enum ci_revision { 110 + CI_REVISION_1X = 10, /* Revision 1.x */ 111 + CI_REVISION_20 = 20, /* Revision 2.0 */ 112 + CI_REVISION_21, /* Revision 2.1 */ 113 + CI_REVISION_22, /* Revision 2.2 */ 114 + CI_REVISION_23, /* Revision 2.3 */ 115 + CI_REVISION_24, /* Revision 2.4 */ 116 + CI_REVISION_25, /* Revision 2.5 */ 117 + CI_REVISION_25_PLUS, /* Revision above than 2.5 */ 118 + CI_REVISION_UNKNOWN = 99, /* Unknown Revision */ 119 + }; 120 + 109 121 /** 110 122 * struct ci_role_driver - host/gadget role driver 111 123 * @start: start this role ··· 193 181 * @supports_runtime_pm: if runtime pm is supported 194 182 * @in_lpm: if the core in low power mode 195 183 * @wakeup_int: if wakeup interrupt occur 184 + * @rev: The revision number for controller 196 185 */ 197 186 struct ci_hdrc { 198 187 struct device *dev; ··· 239 226 bool supports_runtime_pm; 240 227 bool in_lpm; 241 228 bool wakeup_int; 229 + enum ci_revision rev; 242 230 }; 243 231 244 232 static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
+21 -2
drivers/usb/chipidea/core.c
··· 137 137 return 0; 138 138 } 139 139 140 + static enum ci_revision ci_get_revision(struct ci_hdrc *ci) 141 + { 142 + int ver = hw_read_id_reg(ci, ID_ID, VERSION) >> __ffs(VERSION); 143 + enum ci_revision rev = CI_REVISION_UNKNOWN; 144 + 145 + if (ver == 0x2) { 146 + rev = hw_read_id_reg(ci, ID_ID, REVISION) 147 + >> __ffs(REVISION); 148 + rev += CI_REVISION_20; 149 + } else if (ver == 0x0) { 150 + rev = CI_REVISION_1X; 151 + } 152 + 153 + return rev; 154 + } 155 + 140 156 /** 141 157 * hw_read_intr_enable: returns interrupt enable register 142 158 * ··· 267 251 /* Clear all interrupts status bits*/ 268 252 hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff); 269 253 270 - dev_dbg(ci->dev, "ChipIdea HDRC found, lpm: %d; cap: %p op: %p\n", 271 - ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op); 254 + ci->rev = ci_get_revision(ci); 255 + 256 + dev_dbg(ci->dev, 257 + "ChipIdea HDRC found, revision: %d, lpm: %d; cap: %p op: %p\n", 258 + ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op); 272 259 273 260 /* setup lock mode ? */ 274 261