Commit Graph

111 Commits

Author SHA1 Message Date
Christian Lütke-Stetzkamp 370713270e staging: mt7621-mmc: Find response of SD_APP_OP_COND by default
The response type of the SD_APP_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_app_op_cond, correctly places MMC_RSP_R3 in cmd.flags.

So there is no need to treat that opcode separately.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp c3f28802a1 staging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default
The response type of the MMC_SEND_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_op_cond, correctly places MMC_RSP_R3 in cmd.flags.

So there is no need to treat that opcode separately.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp 256e086636 staging: mt7621-mmc: Factor out from msdc_command_start()
Currently msdc_command_start does multiple things and is hard to read,
so factor out the finding of the response type.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp 38ee87eaad staging: mt7621-mmc: Remove unused argument from msdc_do_command
The argument tune of msdc_do_command is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp 008f3853de staging: mt7621-mmc: Remove unused macro is_card_present
The macro is_card_present is unused and also a duplicate of a macro in
mmc, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp 2de186940b staging: mt7621-mmc: Remove unused define MAX_PHY_SGMTS
The define MAX_PHY_SGMTS is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp ed940e7547 staging: mt7621-mmc: Remove unused define IRQ_SDC
The define IRQ_SDC is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp a76187ffa5 staging: mt7621-mmc: Remove unused define RALINK_MSDC_BASE
The define RALINK_MSDC_BASE is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:05 +09:00
Christian Lütke-Stetzkamp 2dfc73d5bb staging: mt7621-mmc: Cleanup source of base address for io
Currently the base address for all io operations is hidden behind a
macro, REG_ADD. This macro uses the symbol "base" as the base address
and all functions set base = host->base. This is hard to read, so the
whole wrapping is removed and host->base is directly inserted in the
io access.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp 6aab8b5308 staging: mt7621-mmc: Remove unused variable from msdc_tune_request
The variable cmd in the function msdc_tune_request is set but never
used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp a98c143734 staging: mt7621-mmc: Remove unused macro MAX_BD_PER_GPD
The macro MAX_BD_PER_GPD is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp 6a1636fa11 staging: mt7621-mmc: Remove unused macro msdc_retry
The macro msdc_retry is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp e327df5e88 staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu
In the current code, msdc_clr_fifo is a macro and just busy waits for
a limited amount of time for the fifo clear to finish. That is not
correct, the programming manual hits, that the user should wait until
the bit is cleared by hardware and not a limited amount of time.

So the code is changed to a function, that also relaxes the cpu while
busy waiting.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp 41015d06e6 staging: mt7621-mmc: Remove unnecessary BUG_ON() in msdc_dma_setup
The BUG_ON() removed by this patch is just a duplicate of a prior
BUG_ON() statement. There the condition is just clearer, it checks
weather sglen > MAX_BD_NUM and MAX_BD_NUM is equal MAX_BD_PER_GPD. So
this statement can be safely removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp d812c6a9bb staging: mt7621-mmc: Remove variable num form msdc_dma_setup
The variable num in msdc_dma_setup is only used for a BUG_ON
statement, so it can be removed by inlining the condition.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp fe219842d6 staging: mt7621-mmc: Remove unused field sglen from msdc_dma
The field sglen from struct msdc_dma is once set and never read, so
remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp acbd652b03 staging: mt7621-mmc: Remove unused field sg from msdc_dma
The field sg from struct msdc_dma is once set and never read, so
remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:04 +09:00
Christian Lütke-Stetzkamp 8cfba8ac75 staging: mt7621-mmc: Refactor dma setup process
Current code uses two functions for dma setup, msdc_dma_config and
msdc_dma_setup. By now msdc_dma_setup is nearly empty and mainly calls
msdc_dma_config, so the later one can be inline into the first
one. While doing this there is also some refactoring done.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp 1668d5fc7b staging: mt7621-mmc: Remove unused field mode from msdc_dma
The field mode of struct msdc_dma has no remaining use, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp f3e1b5766c staging: mt7621-mmc: Remove DMA basic mode code
The driver currently only uses DMA linked mode and the upstream
driver does the same, so remove the basic mode code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp e988d35a62 staging: mt7621-mmc: Replace sdr_read32 with readl
The current code uses a macro (sdr_read32) for reading from hardware,
but it is only a readl, so replace it to get nearer to upstream code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp 8fbcf12087 staging: mt7621-mmc: Replace sdr_write32 with writel
The current code uses a macro (sdr_write32) for writing to hardware,
but it is only a writel with switched arguments, so replace it to get
nearer to upstream code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp 09cb808cfd staging: mt7621-mmc: Remove unused macro msdc_rxfifocnt
The macro msdc_rxfifocnt is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp 98336f9924 staging: mt7621-mmc: Remove unused macro msdc_txfifocnt
The macro msdc_txfifocnt is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:03 +09:00
Christian Lütke-Stetzkamp dbed911180 staging: mt7621-mmc: Remove unused macro msdc_fifo_read32
The macro msdc_fifo_read32 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:02 +09:00
Christian Lütke-Stetzkamp bbe95e2421 staging: mt7621-mmc: Remove unused macro msdc_fifo_write32
The macro msdc_fifo_write32 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:02 +09:00
Christian Lütke-Stetzkamp 12c3ab44fa staging: mt7621-mmc: Remove unused macro msdc_fifo_read8
The macro msdc_fifo_read8 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:02 +09:00
Christian Lütke-Stetzkamp 73384e5275 staging: mt7621-mmc: Remove unused macro msdc_fifo_write8
The macro msdc_fifo_write8 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:02 +09:00
Christian Lütke-Stetzkamp 2e477f9ee5 staging: mt7621-mmc: Remove unused variable in msdc_command_resp
The variable resp in msdc_command_resp is once set and never read,
delete it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 21:48:02 +09:00
Colin Ian King e709e7fe49 staging: mt7621-mmc: fix spelling mistake: "Illgal" -> "Illegal"
Trivial fix to another spelling mistake in N_MSG message text

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25 18:44:13 +02:00
Colin Ian King dbbfae6af1 staging: mt7621-mmc: fix spelling mistake: "Eanable" -> "Enable"
Trivial fix to spelling mistake in N_MSG message text

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-20 14:44:12 +02:00
Christian Lütke-Stetzkamp b06b46059b staging: mt7621-mmc: Remove unused barrier macros
The current code has some barrier macros in it, which are already '#if
0' out, so just remove them.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp f18898631a staging: mt7621-mmc: Cleanup includes
This commit cleans the includes in the sd.c file. Those which are not
needed are removed, the remaining ones are sorted alphabetically.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp 47b7bae694 staging: mt7621-mmc: Remove unused macro HOST_MAX_NUM
The macro HOST_MAX_NUM is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp a0381e2e28 staging: mt7621-mmc: Always use linked DMA mode
Current code uses linked DMA mode only when there is more than one
entry in the scatterlist. But the overhead of the linked DMA is very
small, so the code is easier when only using linked DMA and this is
also the way, the upstream driver mtk-sd handles it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp 759c05d317 staging: mt7621-mmc: Change return value of msdc_dma_config to void
The msdc_dma_config function currently returns always 0. Remove the
return and change to void.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp 37c6325b58 staging: mt7621-mmc: Don't disables DMA
Current code disables the DMA after the transfer. That only changes
the transfer mode to non-DMA and does not save any power. This is not
necessary any more, because now DMA transfer is always used. The macro
for disabling DMA transfer is also removed, because it is not used any
more.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp 32a966cb00 staging: mt7621-mmc: Inline function msdc_set_blknum
The function msdc_set_blknum consists of one (real) line of code and
is only called once, so inline it makes the code shorter and more
readable.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp 96a9789306 staging: mt7621-mmc: Remove initialisation in msdc_dma_config
Current code initialises the variable sg at the beginning of the
msdc_dma_config function. This is not necessary, because the variable
is assigned by the for_each_sg macro later on.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:07 -07:00
Christian Lütke-Stetzkamp f71774ac8a staging: mt7621-mmc: Remove redundant check for card status
Current code checks the card status at the beginning of
msdc_ops_request. This is not necessary because mmc core always checks
the card status before calling this operation.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp eafda89222 staging: mt7621-mmc: Do not BUG() if mrq set in msdc_ops_request
Currently the code BUG()'s, if host->mrq is set at the beginning of
msdc_ops_request. This shoould normally not happen, but it is not that
critical, because the critical sections are protected by a spin lock
and in the worst case, some commands to the card are lost, so it is
sufficient to just WARN_ON().

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp ec7375d1f5 staging: mt7621-mmc: Remove unused sdio irq code
Currently the code for the sdio irq is never used, because the flags
for it (MSDC_(EXT_)SDIO_IRQ) are never set. So the whole code for it
can be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp 23f37ef71c staging: mt7621-mmc: Remove unused field abort from msdc_host
The field abort of msdc_host is only set, but never read, so it can be
removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp ec5e399edd staging: mt7621-mmc: Fix error number assignment
Currently the value that data->error is set to is converted to an
unsigned int, but it is a usual error number, so it should be
negative.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp eb7b0a9344 staging: mt7621-mmc: Remove unused variable dma_xfer from msdc_host
The field dma_xfer of the struct msdc_host is not used anymore, remove
it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp bcdcbfd533 staging: mt7621-mmc: Remove non-DMA transfer code
Currently the driver is capable of DMA and non-DMA transfer. But the
option to choose non-DMA transfer has already been removed. Now remove
also the code for the non-DMA transfer.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:06 -07:00
Christian Lütke-Stetzkamp 1e653f4fd5 staging: mt7621-mmc: Remove transfer mode setting variable
Currently the transfer mode can be chosen between DMA, a size
dependent mode and non-DMA by writing to a proc file. The upstream
driver mtk-sd uses DMA all times. The previous patch removed the
ability to set that option.

Now the remaining uses of the transfer mode setting variable are
cleaned up, because it cannot be changed any more.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:05 -07:00
Christian Lütke-Stetzkamp ab4ce1140a staging: mt7621-mmc: Remove unused static msdc_regs
The static variable msdc_regs is set once, but never used, so remove
it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:05 -07:00
Christian Lütke-Stetzkamp 8f1c27c981 staging: mt7621-mmc: Replace macro sdr_get_field with function
Currently sdr_get_field is a macro, to bring the code in line with the
upstream driver mtk-sd, it is changed to a function.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:05 -07:00
Christian Lütke-Stetzkamp 36b730101d staging: mt7621-mmc: Remove unused macro msdc_init_gpd_ex
The macro msdc_init_gpd_ex is never used and does not provied any
information about the hardware, so it is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06 19:08:05 -07:00