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

usb: chipidea: add identification registers access APIs

Using hw_write_id_reg and hw_read_id_reg to write and read identification
registers contents, they can be used to get controller information, change
some system configurations, and so on.

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
655d32e9 8721a752

+39
+39
drivers/usb/chipidea/ci.h
··· 29 29 /****************************************************************************** 30 30 * REGISTERS 31 31 *****************************************************************************/ 32 + /* Identification Registers */ 33 + #define ID_ID 0x0 34 + #define ID_HWGENERAL 0x4 35 + #define ID_HWHOST 0x8 36 + #define ID_HWDEVICE 0xc 37 + #define ID_HWTXBUF 0x10 38 + #define ID_HWRXBUF 0x14 39 + #define ID_SBUSCFG 0x90 40 + 32 41 /* register indices */ 33 42 enum ci_hw_regs { 34 43 CAP_CAPLENGTH, ··· 260 251 ci->role = CI_ROLE_END; 261 252 262 253 ci->roles[role]->stop(ci); 254 + } 255 + 256 + /** 257 + * hw_read_id_reg: reads from a identification register 258 + * @ci: the controller 259 + * @offset: offset from the beginning of identification registers region 260 + * @mask: bitfield mask 261 + * 262 + * This function returns register contents 263 + */ 264 + static inline u32 hw_read_id_reg(struct ci_hdrc *ci, u32 offset, u32 mask) 265 + { 266 + return ioread32(ci->hw_bank.abs + offset) & mask; 267 + } 268 + 269 + /** 270 + * hw_write_id_reg: writes to a identification register 271 + * @ci: the controller 272 + * @offset: offset from the beginning of identification registers region 273 + * @mask: bitfield mask 274 + * @data: new value 275 + */ 276 + static inline void hw_write_id_reg(struct ci_hdrc *ci, u32 offset, 277 + u32 mask, u32 data) 278 + { 279 + if (~mask) 280 + data = (ioread32(ci->hw_bank.abs + offset) & ~mask) 281 + | (data & mask); 282 + 283 + iowrite32(data, ci->hw_bank.abs + offset); 263 284 } 264 285 265 286 /**