Commit 6a06b6c1 authored by Emmanuel Grumbach's avatar Emmanuel Grumbach Committed by Johannes Berg

iwlwifi: move prph handling into the transport

New transports may handle it internally for better performance.
Also move the tracing inside PRPH access which will make the
output more readable:

iwlwifi_dev_ioread_prph32: Read 0x0 from SCD_AGGR_SEL (32-bit)

instead of the corresponding accesses to HBUS_TARG_PRPH_*.
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent b7998c8b
...@@ -133,6 +133,40 @@ TRACE_EVENT(iwlwifi_dev_iowrite32, ...@@ -133,6 +133,40 @@ TRACE_EVENT(iwlwifi_dev_iowrite32,
__get_str(dev), __entry->offs, __entry->val) __get_str(dev), __entry->offs, __entry->val)
); );
TRACE_EVENT(iwlwifi_dev_iowrite_prph32,
TP_PROTO(const struct device *dev, u32 offs, u32 val),
TP_ARGS(dev, offs, val),
TP_STRUCT__entry(
DEV_ENTRY
__field(u32, offs)
__field(u32, val)
),
TP_fast_assign(
DEV_ASSIGN;
__entry->offs = offs;
__entry->val = val;
),
TP_printk("[%s] write PRPH[%#x] = %#x)",
__get_str(dev), __entry->offs, __entry->val)
);
TRACE_EVENT(iwlwifi_dev_ioread_prph32,
TP_PROTO(const struct device *dev, u32 offs, u32 val),
TP_ARGS(dev, offs, val),
TP_STRUCT__entry(
DEV_ENTRY
__field(u32, offs)
__field(u32, val)
),
TP_fast_assign(
DEV_ASSIGN;
__entry->offs = offs;
__entry->val = val;
),
TP_printk("[%s] read PRPH[%#x] = %#x",
__get_str(dev), __entry->offs, __entry->val)
);
TRACE_EVENT(iwlwifi_dev_irq, TRACE_EVENT(iwlwifi_dev_irq,
TP_PROTO(const struct device *dev), TP_PROTO(const struct device *dev),
TP_ARGS(dev), TP_ARGS(dev),
......
...@@ -214,84 +214,84 @@ int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, ...@@ -214,84 +214,84 @@ int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
} }
EXPORT_SYMBOL_GPL(iwl_poll_direct_bit); EXPORT_SYMBOL_GPL(iwl_poll_direct_bit);
static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 reg) static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 ofs)
{ {
iwl_write32(trans, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); u32 val = iwl_trans_read_prph(trans, ofs);
return iwl_read32(trans, HBUS_TARG_PRPH_RDAT); trace_iwlwifi_dev_ioread_prph32(trans->dev, ofs, val);
return val;
} }
static inline void __iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) static inline void __iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
{ {
iwl_write32(trans, HBUS_TARG_PRPH_WADDR, trace_iwlwifi_dev_iowrite_prph32(trans->dev, ofs, val);
((addr & 0x0000FFFF) | (3 << 24))); iwl_trans_write_prph(trans, ofs, val);
iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val);
} }
u32 iwl_read_prph(struct iwl_trans *trans, u32 reg) u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs)
{ {
unsigned long flags; unsigned long flags;
u32 val; u32 val;
spin_lock_irqsave(&trans->reg_lock, flags); spin_lock_irqsave(&trans->reg_lock, flags);
iwl_grab_nic_access(trans); iwl_grab_nic_access(trans);
val = __iwl_read_prph(trans, reg); val = __iwl_read_prph(trans, ofs);
iwl_release_nic_access(trans); iwl_release_nic_access(trans);
spin_unlock_irqrestore(&trans->reg_lock, flags); spin_unlock_irqrestore(&trans->reg_lock, flags);
return val; return val;
} }
EXPORT_SYMBOL_GPL(iwl_read_prph); EXPORT_SYMBOL_GPL(iwl_read_prph);
void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&trans->reg_lock, flags); spin_lock_irqsave(&trans->reg_lock, flags);
if (likely(iwl_grab_nic_access(trans))) { if (likely(iwl_grab_nic_access(trans))) {
__iwl_write_prph(trans, addr, val); __iwl_write_prph(trans, ofs, val);
iwl_release_nic_access(trans); iwl_release_nic_access(trans);
} }
spin_unlock_irqrestore(&trans->reg_lock, flags); spin_unlock_irqrestore(&trans->reg_lock, flags);
} }
EXPORT_SYMBOL_GPL(iwl_write_prph); EXPORT_SYMBOL_GPL(iwl_write_prph);
void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&trans->reg_lock, flags); spin_lock_irqsave(&trans->reg_lock, flags);
if (likely(iwl_grab_nic_access(trans))) { if (likely(iwl_grab_nic_access(trans))) {
__iwl_write_prph(trans, reg, __iwl_write_prph(trans, ofs,
__iwl_read_prph(trans, reg) | mask); __iwl_read_prph(trans, ofs) | mask);
iwl_release_nic_access(trans); iwl_release_nic_access(trans);
} }
spin_unlock_irqrestore(&trans->reg_lock, flags); spin_unlock_irqrestore(&trans->reg_lock, flags);
} }
EXPORT_SYMBOL_GPL(iwl_set_bits_prph); EXPORT_SYMBOL_GPL(iwl_set_bits_prph);
void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg, void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
u32 bits, u32 mask) u32 bits, u32 mask)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&trans->reg_lock, flags); spin_lock_irqsave(&trans->reg_lock, flags);
if (likely(iwl_grab_nic_access(trans))) { if (likely(iwl_grab_nic_access(trans))) {
__iwl_write_prph(trans, reg, __iwl_write_prph(trans, ofs,
(__iwl_read_prph(trans, reg) & mask) | bits); (__iwl_read_prph(trans, ofs) & mask) | bits);
iwl_release_nic_access(trans); iwl_release_nic_access(trans);
} }
spin_unlock_irqrestore(&trans->reg_lock, flags); spin_unlock_irqrestore(&trans->reg_lock, flags);
} }
EXPORT_SYMBOL_GPL(iwl_set_bits_mask_prph); EXPORT_SYMBOL_GPL(iwl_set_bits_mask_prph);
void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask)
{ {
unsigned long flags; unsigned long flags;
u32 val; u32 val;
spin_lock_irqsave(&trans->reg_lock, flags); spin_lock_irqsave(&trans->reg_lock, flags);
if (likely(iwl_grab_nic_access(trans))) { if (likely(iwl_grab_nic_access(trans))) {
val = __iwl_read_prph(trans, reg); val = __iwl_read_prph(trans, ofs);
__iwl_write_prph(trans, reg, (val & ~mask)); __iwl_write_prph(trans, ofs, (val & ~mask));
iwl_release_nic_access(trans); iwl_release_nic_access(trans);
} }
spin_unlock_irqrestore(&trans->reg_lock, flags); spin_unlock_irqrestore(&trans->reg_lock, flags);
......
...@@ -69,12 +69,12 @@ u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg); ...@@ -69,12 +69,12 @@ u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg);
void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value); void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value);
u32 iwl_read_prph(struct iwl_trans *trans, u32 reg); u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs);
void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val); void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val);
void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask); void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg, void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
u32 bits, u32 mask); u32 bits, u32 mask);
void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask); void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
void _iwl_read_targ_mem_dwords(struct iwl_trans *trans, u32 addr, void _iwl_read_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
void *buf, int dwords); void *buf, int dwords);
......
...@@ -385,6 +385,8 @@ struct iwl_trans; ...@@ -385,6 +385,8 @@ struct iwl_trans;
* @write8: write a u8 to a register at offset ofs from the BAR * @write8: write a u8 to a register at offset ofs from the BAR
* @write32: write a u32 to a register at offset ofs from the BAR * @write32: write a u32 to a register at offset ofs from the BAR
* @read32: read a u32 register at offset ofs from the BAR * @read32: read a u32 register at offset ofs from the BAR
* @read_prph: read a DWORD from a periphery register
* @write_prph: write a DWORD to a periphery register
* @configure: configure parameters required by the transport layer from * @configure: configure parameters required by the transport layer from
* the op_mode. May be called several times before start_fw, can't be * the op_mode. May be called several times before start_fw, can't be
* called after that. * called after that.
...@@ -420,6 +422,8 @@ struct iwl_trans_ops { ...@@ -420,6 +422,8 @@ struct iwl_trans_ops {
void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val);
void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val);
u32 (*read32)(struct iwl_trans *trans, u32 ofs); u32 (*read32)(struct iwl_trans *trans, u32 ofs);
u32 (*read_prph)(struct iwl_trans *trans, u32 ofs);
void (*write_prph)(struct iwl_trans *trans, u32 ofs, u32 val);
void (*configure)(struct iwl_trans *trans, void (*configure)(struct iwl_trans *trans,
const struct iwl_trans_config *trans_cfg); const struct iwl_trans_config *trans_cfg);
void (*set_pmi)(struct iwl_trans *trans, bool state); void (*set_pmi)(struct iwl_trans *trans, bool state);
...@@ -664,6 +668,17 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) ...@@ -664,6 +668,17 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs)
return trans->ops->read32(trans, ofs); return trans->ops->read32(trans, ofs);
} }
static inline u32 iwl_trans_read_prph(struct iwl_trans *trans, u32 ofs)
{
return trans->ops->read_prph(trans, ofs);
}
static inline void iwl_trans_write_prph(struct iwl_trans *trans, u32 ofs,
u32 val)
{
return trans->ops->write_prph(trans, ofs, val);
}
static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state) static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state)
{ {
trans->ops->set_pmi(trans, state); trans->ops->set_pmi(trans, state);
......
...@@ -668,6 +668,20 @@ static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) ...@@ -668,6 +668,20 @@ static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs)
return readl(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); return readl(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs);
} }
static u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg)
{
iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
return iwl_trans_pcie_read32(trans, HBUS_TARG_PRPH_RDAT);
}
static void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr,
u32 val)
{
iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WADDR,
((addr & 0x0000FFFF) | (3 << 24)));
iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WDAT, val);
}
static void iwl_trans_pcie_configure(struct iwl_trans *trans, static void iwl_trans_pcie_configure(struct iwl_trans *trans,
const struct iwl_trans_config *trans_cfg) const struct iwl_trans_config *trans_cfg)
{ {
...@@ -1223,6 +1237,8 @@ static const struct iwl_trans_ops trans_ops_pcie = { ...@@ -1223,6 +1237,8 @@ static const struct iwl_trans_ops trans_ops_pcie = {
.write8 = iwl_trans_pcie_write8, .write8 = iwl_trans_pcie_write8,
.write32 = iwl_trans_pcie_write32, .write32 = iwl_trans_pcie_write32,
.read32 = iwl_trans_pcie_read32, .read32 = iwl_trans_pcie_read32,
.read_prph = iwl_trans_pcie_read_prph,
.write_prph = iwl_trans_pcie_write_prph,
.configure = iwl_trans_pcie_configure, .configure = iwl_trans_pcie_configure,
.set_pmi = iwl_trans_pcie_set_pmi, .set_pmi = iwl_trans_pcie_set_pmi,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment