Skip to content

Commit 940692c

Browse files
3x380Vtsbogend
authored andcommitted
MIPS: OCTEON: octeon-usb: use bitfields for shim register
Use Linux standard bitfield access macros to manipulate shim register. Signed-off-by: Ladislav Michl <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 74ac367 commit 940692c

File tree

1 file changed

+41
-55
lines changed

1 file changed

+41
-55
lines changed

arch/mips/cavium-octeon/octeon-usb.c

Lines changed: 41 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -152,57 +152,43 @@
152152
*/
153153
# define USBDRD_UCTL_HOST_PPC_ACTIVE_HIGH_EN BIT(24)
154154

155+
/*
156+
* UCTL Shim Features Register
157+
*/
155158
#define USBDRD_UCTL_SHIM_CFG 0xe8
159+
/* Out-of-bound UAHC register access: 0 = read, 1 = write */
160+
# define USBDRD_UCTL_SHIM_CFG_XS_NCB_OOB_WRN BIT(63)
161+
/* SRCID error log for out-of-bound UAHC register access:
162+
* [59:58] = chipID
163+
* [57] = Request source: 0 = core, 1 = NCB-device
164+
* [56:51] = Core/NCB-device number, [56] always 0 for NCB devices
165+
* [50:48] = SubID
166+
*/
167+
# define USBDRD_UCTL_SHIM_CFG_XS_NCB_OOB_OSRC GENMASK(59, 48)
168+
/* Error log for bad UAHC DMA access: 0 = Read log, 1 = Write log */
169+
# define USBDRD_UCTL_SHIM_CFG_XM_BAD_DMA_WRN BIT(47)
170+
/* Encoded error type for bad UAHC DMA */
171+
# define USBDRD_UCTL_SHIM_CFG_XM_BAD_DMA_TYPE GENMASK(43, 40)
172+
/* Select the IOI read command used by DMA accesses */
173+
# define USBDRD_UCTL_SHIM_CFG_DMA_READ_CMD BIT(12)
174+
/* Select endian format for DMA accesses to the L2C:
175+
* 0x0 = Little endian
176+
* 0x1 = Big endian
177+
* 0x2 = Reserved
178+
* 0x3 = Reserved
179+
*/
180+
# define USBDRD_UCTL_SHIM_CFG_DMA_ENDIAN_MODE GENMASK(9, 8)
181+
/* Select endian format for IOI CSR access to UAHC:
182+
* 0x0 = Little endian
183+
* 0x1 = Big endian
184+
* 0x2 = Reserved
185+
* 0x3 = Reserved
186+
*/
187+
# define USBDRD_UCTL_SHIM_CFG_CSR_ENDIAN_MODE GENMASK(1, 0)
188+
156189
#define USBDRD_UCTL_ECC 0xf0
157190
#define USBDRD_UCTL_SPARE1 0xf8
158191

159-
/* UCTL Shim Features Register */
160-
union cvm_usbdrd_uctl_shim_cfg {
161-
uint64_t u64;
162-
struct cvm_usbdrd_uctl_shim_cfg_s {
163-
/* Out-of-bound UAHC register access: 0 = read, 1 = write */
164-
__BITFIELD_FIELD(uint64_t xs_ncb_oob_wrn:1,
165-
/* Reserved */
166-
__BITFIELD_FIELD(uint64_t reserved_60_62:3,
167-
/* SRCID error log for out-of-bound UAHC register access:
168-
* [59:58] = chipID
169-
* [57] = Request source: 0 = core, 1 = NCB-device
170-
* [56:51] = Core/NCB-device number, [56] always 0 for NCB devices
171-
* [50:48] = SubID
172-
*/
173-
__BITFIELD_FIELD(uint64_t xs_ncb_oob_osrc:12,
174-
/* Error log for bad UAHC DMA access: 0 = Read log, 1 = Write log */
175-
__BITFIELD_FIELD(uint64_t xm_bad_dma_wrn:1,
176-
/* Reserved */
177-
__BITFIELD_FIELD(uint64_t reserved_44_46:3,
178-
/* Encoded error type for bad UAHC DMA */
179-
__BITFIELD_FIELD(uint64_t xm_bad_dma_type:4,
180-
/* Reserved */
181-
__BITFIELD_FIELD(uint64_t reserved_13_39:27,
182-
/* Select the IOI read command used by DMA accesses */
183-
__BITFIELD_FIELD(uint64_t dma_read_cmd:1,
184-
/* Reserved */
185-
__BITFIELD_FIELD(uint64_t reserved_10_11:2,
186-
/* Select endian format for DMA accesses to the L2c:
187-
* 0x0 = Little endian
188-
*` 0x1 = Big endian
189-
* 0x2 = Reserved
190-
* 0x3 = Reserved
191-
*/
192-
__BITFIELD_FIELD(uint64_t dma_endian_mode:2,
193-
/* Reserved */
194-
__BITFIELD_FIELD(uint64_t reserved_2_7:6,
195-
/* Select endian format for IOI CSR access to UAHC:
196-
* 0x0 = Little endian
197-
*` 0x1 = Big endian
198-
* 0x2 = Reserved
199-
* 0x3 = Reserved
200-
*/
201-
__BITFIELD_FIELD(uint64_t csr_endian_mode:2,
202-
;))))))))))))
203-
} s;
204-
};
205-
206192
#define OCTEON_H_CLKDIV_SEL 8
207193
#define OCTEON_MIN_H_CLK_RATE 150000000
208194
#define OCTEON_MAX_H_CLK_RATE 300000000
@@ -456,17 +442,17 @@ static int dwc3_octeon_clocks_start(struct device *dev, u64 base)
456442

457443
static void __init dwc3_octeon_set_endian_mode(u64 base)
458444
{
459-
union cvm_usbdrd_uctl_shim_cfg shim_cfg;
445+
u64 val;
446+
u64 uctl_shim_cfg_reg = base + USBDRD_UCTL_SHIM_CFG;
460447

461-
shim_cfg.u64 = cvmx_read_csr(base + USBDRD_UCTL_SHIM_CFG);
448+
val = cvmx_read_csr(uctl_shim_cfg_reg);
449+
val &= ~USBDRD_UCTL_SHIM_CFG_DMA_ENDIAN_MODE;
450+
val &= ~USBDRD_UCTL_SHIM_CFG_CSR_ENDIAN_MODE;
462451
#ifdef __BIG_ENDIAN
463-
shim_cfg.s.dma_endian_mode = 1;
464-
shim_cfg.s.csr_endian_mode = 1;
465-
#else
466-
shim_cfg.s.dma_endian_mode = 0;
467-
shim_cfg.s.csr_endian_mode = 0;
452+
val |= FIELD_PREP(USBDRD_UCTL_SHIM_CFG_DMA_ENDIAN_MODE, 1);
453+
val |= FIELD_PREP(USBDRD_UCTL_SHIM_CFG_CSR_ENDIAN_MODE, 1);
468454
#endif
469-
cvmx_write_csr(base + USBDRD_UCTL_SHIM_CFG, shim_cfg.u64);
455+
cvmx_write_csr(uctl_shim_cfg_reg, val);
470456
}
471457

472458
static void __init dwc3_octeon_phy_reset(u64 base)

0 commit comments

Comments
 (0)