Commit 95a31ef1 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

staging: most: dim2-hdm: introduce function dim2_transfer_madr

This patch removes duplicated code by putting it into the new function
dim2_transfer_madr.
Signed-off-by: default avatarAndrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9fe7aeac
...@@ -135,6 +135,17 @@ static void free_dbr(int offs, int size) ...@@ -135,6 +135,17 @@ static void free_dbr(int offs, int size)
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static void dim2_transfer_madr(u32 val)
{
dimcb_io_write(&g.dim2->MADR, val);
/* wait for transfer completion */
while ((dimcb_io_read(&g.dim2->MCTL) & 1) != 1)
continue;
dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */
}
static void dim2_clear_dbr(u16 addr, u16 size) static void dim2_clear_dbr(u16 addr, u16 size)
{ {
enum { MADR_TB_BIT = 30, MADR_WNR_BIT = 31 }; enum { MADR_TB_BIT = 30, MADR_WNR_BIT = 31 };
...@@ -145,26 +156,13 @@ static void dim2_clear_dbr(u16 addr, u16 size) ...@@ -145,26 +156,13 @@ static void dim2_clear_dbr(u16 addr, u16 size)
dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */ dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */
dimcb_io_write(&g.dim2->MDAT0, 0); dimcb_io_write(&g.dim2->MDAT0, 0);
for (; addr < end_addr; addr++) { for (; addr < end_addr; addr++)
dimcb_io_write(&g.dim2->MADR, cmd | addr); dim2_transfer_madr(cmd | addr);
/* wait till transfer is completed */
while ((dimcb_io_read(&g.dim2->MCTL) & 1) != 1)
continue;
dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */
}
} }
static u32 dim2_read_ctr(u32 ctr_addr, u16 mdat_idx) static u32 dim2_read_ctr(u32 ctr_addr, u16 mdat_idx)
{ {
dimcb_io_write(&g.dim2->MADR, ctr_addr); dim2_transfer_madr(ctr_addr);
/* wait till transfer is completed */
while ((dimcb_io_read(&g.dim2->MCTL) & 1) != 1)
continue;
dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */
return dimcb_io_read((&g.dim2->MDAT0) + mdat_idx); return dimcb_io_read((&g.dim2->MDAT0) + mdat_idx);
} }
...@@ -189,13 +187,7 @@ static void dim2_write_ctr_mask(u32 ctr_addr, const u32 *mask, const u32 *value) ...@@ -189,13 +187,7 @@ static void dim2_write_ctr_mask(u32 ctr_addr, const u32 *mask, const u32 *value)
dimcb_io_write(&g.dim2->MDWE2, mask[2]); dimcb_io_write(&g.dim2->MDWE2, mask[2]);
dimcb_io_write(&g.dim2->MDWE3, mask[3]); dimcb_io_write(&g.dim2->MDWE3, mask[3]);
dimcb_io_write(&g.dim2->MADR, bit_mask(MADR_WNR_BIT) | ctr_addr); dim2_transfer_madr(bit_mask(MADR_WNR_BIT) | ctr_addr);
/* wait till transfer is completed */
while ((dimcb_io_read(&g.dim2->MCTL) & 1) != 1)
continue;
dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */
} }
static inline void dim2_write_ctr(u32 ctr_addr, const u32 *value) static inline void dim2_write_ctr(u32 ctr_addr, const u32 *value)
......
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