Skip to content

Commit 7c81a57

Browse files
Gil Finewesteri
authored andcommitted
thunderbolt: Move constants related to NVM into nvm.c
Move constants related to NVM into nvm.c to make the code cleaner. Use a separate constant for USB4_DATA_DWORDS in usb4.c. No functional changes. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
1 parent f2bfa94 commit 7c81a57

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/thunderbolt/nvm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
#include "tb.h"
1414

15+
#define NVM_MIN_SIZE SZ_32K
16+
#define NVM_MAX_SIZE SZ_512K
17+
#define NVM_DATA_DWORDS 16
18+
1519
/* Intel specific NVM offsets */
1620
#define INTEL_NVM_DEVID 0x05
1721
#define INTEL_NVM_VERSION 0x08

drivers/thunderbolt/tb.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
#include "ctl.h"
2020
#include "dma_port.h"
2121

22-
#define NVM_MIN_SIZE SZ_32K
23-
#define NVM_MAX_SIZE SZ_512K
24-
#define NVM_DATA_DWORDS 16
25-
2622
/* Keep link controller awake during update */
2723
#define QUIRK_FORCE_POWER_LINK_CONTROLLER BIT(0)
2824
/* Disable CLx if not supported */

drivers/thunderbolt/usb4.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "tb.h"
1616

1717
#define USB4_DATA_RETRIES 3
18+
#define USB4_DATA_DWORDS 16
1819

1920
enum usb4_sb_target {
2021
USB4_SB_TARGET_ROUTER,
@@ -112,7 +113,7 @@ static int __usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata,
112113
{
113114
const struct tb_cm_ops *cm_ops = sw->tb->cm_ops;
114115

115-
if (tx_dwords > NVM_DATA_DWORDS || rx_dwords > NVM_DATA_DWORDS)
116+
if (tx_dwords > USB4_DATA_DWORDS || rx_dwords > USB4_DATA_DWORDS)
116117
return -EINVAL;
117118

118119
/*
@@ -702,7 +703,7 @@ int usb4_switch_credits_init(struct tb_switch *sw)
702703
int max_usb3, min_dp_aux, min_dp_main, max_pcie, max_dma;
703704
int ret, length, i, nports;
704705
const struct tb_port *port;
705-
u32 data[NVM_DATA_DWORDS];
706+
u32 data[USB4_DATA_DWORDS];
706707
u32 metadata = 0;
707708
u8 status = 0;
708709

@@ -1198,7 +1199,7 @@ static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit,
11981199

11991200
static int usb4_port_read_data(struct tb_port *port, void *data, size_t dwords)
12001201
{
1201-
if (dwords > NVM_DATA_DWORDS)
1202+
if (dwords > USB4_DATA_DWORDS)
12021203
return -EINVAL;
12031204

12041205
return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2,
@@ -1208,7 +1209,7 @@ static int usb4_port_read_data(struct tb_port *port, void *data, size_t dwords)
12081209
static int usb4_port_write_data(struct tb_port *port, const void *data,
12091210
size_t dwords)
12101211
{
1211-
if (dwords > NVM_DATA_DWORDS)
1212+
if (dwords > USB4_DATA_DWORDS)
12121213
return -EINVAL;
12131214

12141215
return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2,
@@ -1844,7 +1845,7 @@ static int usb4_port_retimer_nvm_read_block(void *data, unsigned int dwaddress,
18441845
int ret;
18451846

18461847
metadata = dwaddress << USB4_NVM_READ_OFFSET_SHIFT;
1847-
if (dwords < NVM_DATA_DWORDS)
1848+
if (dwords < USB4_DATA_DWORDS)
18481849
metadata |= dwords << USB4_NVM_READ_LENGTH_SHIFT;
18491850

18501851
ret = usb4_port_retimer_write(port, index, USB4_SB_METADATA, &metadata,

0 commit comments

Comments
 (0)