Commit 74fe0c4d authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: SOF: ops: add readb/writeb helpers

These will be used to add more consistency in the SOF core and
drivers.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20221024165310.246183-4-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 42b00e9d
...@@ -302,6 +302,15 @@ static inline int snd_sof_debugfs_add_region_item(struct snd_sof_dev *sdev, ...@@ -302,6 +302,15 @@ static inline int snd_sof_debugfs_add_region_item(struct snd_sof_dev *sdev,
} }
/* register IO */ /* register IO */
static inline void snd_sof_dsp_writeb(struct snd_sof_dev *sdev, u32 bar,
u32 offset, u8 value)
{
if (sof_ops(sdev)->writeb)
sof_ops(sdev)->writeb(sdev, sdev->bar[bar] + offset, value);
else
writeb(value, sdev->bar[bar] + offset);
}
static inline void snd_sof_dsp_write(struct snd_sof_dev *sdev, u32 bar, static inline void snd_sof_dsp_write(struct snd_sof_dev *sdev, u32 bar,
u32 offset, u32 value) u32 offset, u32 value)
{ {
...@@ -320,6 +329,15 @@ static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar, ...@@ -320,6 +329,15 @@ static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar,
writeq(value, sdev->bar[bar] + offset); writeq(value, sdev->bar[bar] + offset);
} }
static inline u8 snd_sof_dsp_readb(struct snd_sof_dev *sdev, u32 bar,
u32 offset)
{
if (sof_ops(sdev)->readb)
return sof_ops(sdev)->readb(sdev, sdev->bar[bar] + offset);
else
return readb(sdev->bar[bar] + offset);
}
static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar, static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar,
u32 offset) u32 offset)
{ {
......
...@@ -171,6 +171,10 @@ struct snd_sof_dsp_ops { ...@@ -171,6 +171,10 @@ struct snd_sof_dsp_ops {
* TODO: consider removing these operations and calling respective * TODO: consider removing these operations and calling respective
* implementations directly * implementations directly
*/ */
void (*writeb)(struct snd_sof_dev *sof_dev, void __iomem *addr,
u8 value); /* optional */
u8 (*readb)(struct snd_sof_dev *sof_dev,
void __iomem *addr); /* optional */
void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr, void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
u32 value); /* optional */ u32 value); /* optional */
u32 (*read)(struct snd_sof_dev *sof_dev, u32 (*read)(struct snd_sof_dev *sof_dev,
......
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