Fixup mediatek spi driver
Subsystems (2)
v2 cover Fixup mediatek spi driver
This series are based on 4.2-rc1 and provide four patches to fix mediatek spi driver.
Change in v2:
1. The patch "spi: mediatek: remove redundant clock in prepare_hardware/unprepare_hardware" is applied, so remove it from series.
2. fix incorrect endian usage to support little-endian and big-endian system.
3. revise quirks style to bool.
4. use BIT() to instead of SPI_CMD_*_OFFSET.
5. revise coding style, such as time name, and variable type.
PATCH v2 1/4 spi: mediatek: fix spi incorrect endian usage
TX_ENDIAN/RX_ENDIAN bits define whether to reverse the endian order of the data DMA from/to memory. The endian order should keep the same with cpu endian.
--- drivers/spi/spi-mt65xx.c | 38 ++++++++++++++------------------ include/linux/platform_data/spi-mt65xx.h | 2 -- 2 files changed, 16 insertions(+), 24 deletions(-)
drivers/spi/spi-mt65xx.c +16 -22
@@ -122,8 +122,6 @@ static const struct mtk_spi_compatible mt8173_compat = {static const struct mtk_chip_config mtk_default_chip_info = { .rx_mlsb =1 , .tx_mlsb =1 , - .tx_endian =0 , - .rx_endian =0 , };static const struct of_device_id mtk_spi_of_match[] = {
@@ -161,9 +159,13 @@ static void mtk_spi_config(struct mtk_spi *mdata, reg_val |= (chip_config->rx_mlsb <<SPI_CMD_RXMSBF_OFFSET );/* set the tx/rx endian */ - reg_val &= ~(SPI_CMD_TX_ENDIAN |SPI_CMD_RX_ENDIAN ); - reg_val |= (chip_config->tx_endian <<SPI_CMD_TX_ENDIAN_OFFSET ); - reg_val |= (chip_config->rx_endian <<SPI_CMD_RX_ENDIAN_OFFSET ); +#ifdef __LITTLE_ENDIAN + reg_val &= ~SPI_CMD_TX_ENDIAN ; + reg_val &= ~SPI_CMD_RX_ENDIAN ; +#else + reg_val |=SPI_CMD_TX_ENDIAN ; + reg_val |=SPI_CMD_RX_ENDIAN ; +#endif /* set finish and pause interrupt always enable */ reg_val |=SPI_CMD_FINISH_IE |SPI_CMD_PAUSE_EN ;
@@ -352,7 +354,7 @@ static int mtk_spi_fifo_transfer(struct spi_master *master,struct spi_device *spi, struct spi_transfer *xfer) { - int cnt, i; + int cnt;struct mtk_spi *mdata =spi_master_get_devdata (master); mdata->cur_transfer = xfer;
@@ -364,10 +366,7 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, cnt = xfer->len /4 +1 ; else cnt = xfer->len /4 ; - -for (i =0 ; i < cnt; i++) -writel (*((u32 *)xfer->tx_buf + i), - mdata->base +SPI_TX_DATA_REG ); +iowrite32_rep (mdata->base +SPI_TX_DATA_REG , xfer->tx_buf, cnt);mtk_spi_enable_transfer (master);
@@ -437,7 +436,7 @@ static bool mtk_spi_can_dma(struct spi_master *master,static irqreturn_t mtk_spi_interrupt (int irq,void *dev_id) { -u32 cmd, reg_val, i; +u32 cmd, reg_val, cnt;struct spi_master *master = dev_id;struct mtk_spi *mdata =spi_master_get_devdata (master);struct spi_transfer *trans = mdata->cur_transfer;
@@ -449,18 +448,13 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) mdata->state =MTK_SPI_IDLE ;if (!master->can_dma (master, master->cur_msg->spi, trans)) { -/* xfer len is not N*4 bytes every time in a transfer, -* but SPI_RX_DATA_REG must reads 4 bytes once, -* so rx buffer byte by byte. -*/ if (trans->rx_buf) { -for (i =0 ; i < mdata->xfer_len; i++) { -if (i %4 ==0 ) - reg_val = -readl (mdata->base +SPI_RX_DATA_REG ); - *((u8 *)(trans->rx_buf + i)) = - (reg_val >> ((i %4 ) *8 )) &0xff ; - } +if (mdata->xfer_len %4 ) + cnt = mdata->xfer_len /4 +1 ; +else + cnt = mdata->xfer_len /4 ; +ioread32_rep (mdata->base +SPI_RX_DATA_REG , + trans->rx_buf, cnt); }spi_finalize_current_transfer (master);return IRQ_HANDLED ;
include/linux/platform_data/spi-mt65xx.h +0 -2
@@ -16,7 +16,5 @@struct mtk_chip_config {u32 tx_mlsb;u32 rx_mlsb; -u32 tx_endian; -u32 rx_endian; };#endif
Signature · 1 line
1.8.1.1.dirty
A message that is not in the archive (sent off-list or not yet received): 1440062349-25513-2-git-send-email-leilk.liu-NuS5LvNUpcJWk0Htik3J/[email protected]
Applied "spi: mediatek: fix spi incorrect endian usage" to the spi tree
The patch
spi: mediatek: fix spi incorrect endian usage
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
44f636da4e71e0c73d6e29d0319a8954ce3f247aMon Sep 17 00:00:00 2001
From: Leilk Liu <leilk.liu-NuS5LvNUpcJWk0Htik3J/[email protected]>
Date: Thu, 20 Aug 2015 17:19:06 +0800
Subject: [PATCH] spi: mediatek: fix spi incorrect endian usage
TX_ENDIAN/RX_ENDIAN bits define whether to reverse the endian order of the data DMA from/to memory. The endian order should keep the same with cpu endian.
--- drivers/spi/spi-mt65xx.c | 38 ++++++++++++++------------------ include/linux/platform_data/spi-mt65xx.h | 2 -- 2 files changed, 16 insertions(+), 24 deletions(-)
drivers/spi/spi-mt65xx.c +16 -22
@@ -122,8 +122,6 @@ static const struct mtk_spi_compatible mt8173_compat = {static const struct mtk_chip_config mtk_default_chip_info = { .rx_mlsb =1 , .tx_mlsb =1 , - .tx_endian =0 , - .rx_endian =0 , };static const struct of_device_id mtk_spi_of_match[] = {
@@ -161,9 +159,13 @@ static void mtk_spi_config(struct mtk_spi *mdata, reg_val |= (chip_config->rx_mlsb <<SPI_CMD_RXMSBF_OFFSET );/* set the tx/rx endian */ - reg_val &= ~(SPI_CMD_TX_ENDIAN |SPI_CMD_RX_ENDIAN ); - reg_val |= (chip_config->tx_endian <<SPI_CMD_TX_ENDIAN_OFFSET ); - reg_val |= (chip_config->rx_endian <<SPI_CMD_RX_ENDIAN_OFFSET ); +#ifdef __LITTLE_ENDIAN + reg_val &= ~SPI_CMD_TX_ENDIAN ; + reg_val &= ~SPI_CMD_RX_ENDIAN ; +#else + reg_val |=SPI_CMD_TX_ENDIAN ; + reg_val |=SPI_CMD_RX_ENDIAN ; +#endif /* set finish and pause interrupt always enable */ reg_val |=SPI_CMD_FINISH_IE |SPI_CMD_PAUSE_EN ;
@@ -352,7 +354,7 @@ static int mtk_spi_fifo_transfer(struct spi_master *master,struct spi_device *spi, struct spi_transfer *xfer) { - int cnt, i; + int cnt;struct mtk_spi *mdata =spi_master_get_devdata (master); mdata->cur_transfer = xfer;
@@ -364,10 +366,7 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, cnt = xfer->len /4 +1 ; else cnt = xfer->len /4 ; - -for (i =0 ; i < cnt; i++) -writel (*((u32 *)xfer->tx_buf + i), - mdata->base +SPI_TX_DATA_REG ); +iowrite32_rep (mdata->base +SPI_TX_DATA_REG , xfer->tx_buf, cnt);mtk_spi_enable_transfer (master);
@@ -437,7 +436,7 @@ static bool mtk_spi_can_dma(struct spi_master *master,static irqreturn_t mtk_spi_interrupt (int irq,void *dev_id) { -u32 cmd, reg_val, i; +u32 cmd, reg_val, cnt;struct spi_master *master = dev_id;struct mtk_spi *mdata =spi_master_get_devdata (master);struct spi_transfer *trans = mdata->cur_transfer;
@@ -449,18 +448,13 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) mdata->state =MTK_SPI_IDLE ;if (!master->can_dma (master, master->cur_msg->spi, trans)) { -/* xfer len is not N*4 bytes every time in a transfer, -* but SPI_RX_DATA_REG must reads 4 bytes once, -* so rx buffer byte by byte. -*/ if (trans->rx_buf) { -for (i =0 ; i < mdata->xfer_len; i++) { -if (i %4 ==0 ) - reg_val = -readl (mdata->base +SPI_RX_DATA_REG ); - *((u8 *)(trans->rx_buf + i)) = - (reg_val >> ((i %4 ) *8 )) &0xff ; - } +if (mdata->xfer_len %4 ) + cnt = mdata->xfer_len /4 +1 ; +else + cnt = mdata->xfer_len /4 ; +ioread32_rep (mdata->base +SPI_RX_DATA_REG , + trans->rx_buf, cnt); }spi_finalize_current_transfer (master);return IRQ_HANDLED ;
include/linux/platform_data/spi-mt65xx.h +0 -2
@@ -16,7 +16,5 @@struct mtk_chip_config {u32 tx_mlsb;u32 rx_mlsb; -u32 tx_endian; -u32 rx_endian; };#endif
Signature · 6 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/4 spi: medaitek: revise quirks compatibility style
In reply to Leilk LiuThe quirks are true/false, so define these as bool.
--- drivers/spi/spi-mt65xx.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
drivers/spi/spi-mt65xx.c +7 -18
@@ -71,10 +71,6 @@#define SPI_CMD_FINISH_IE BIT(16)#define SPI_CMD_PAUSE_IE BIT(17) -#define MTK_SPI_QUIRK_PAD_SELECT 1 -/* Must explicitly send dummy Tx bytes to do Rx only transfer */ -#define MTK_SPI_QUIRK_MUST_TX 1 -#define MT8173_SPI_MAX_PAD_SEL 3#define MTK_SPI_IDLE 0
@@ -84,8 +80,9 @@#define MTK_SPI_PACKET_SIZE 1024struct mtk_spi_compatible { -u32 need_pad_sel; -u32 must_tx; +bool need_pad_sel; +/* Must explicitly send dummy Tx bytes to do Rx only transfer */ +bool must_tx; };struct mtk_spi {
@@ -100,19 +97,11 @@ struct mtk_spi {const struct mtk_spi_compatible *dev_comp; }; -static const struct mtk_spi_compatible mt6589_compat = { - .need_pad_sel =0 , - .must_tx =0 , -}; - -static const struct mtk_spi_compatible mt8135_compat = { - .need_pad_sel =0 , - .must_tx =0 , -}; - +static const struct mtk_spi_compatible mt6589_compat; +static const struct mtk_spi_compatible mt8135_compat;static const struct mtk_spi_compatible mt8173_compat = { - .need_pad_sel =MTK_SPI_QUIRK_PAD_SELECT , - .must_tx =MTK_SPI_QUIRK_MUST_TX , + .need_pad_sel = true, + .must_tx = true, };/*
Signature · 1 line
1.8.1.1.dirty
A message that is not in the archive (sent off-list or not yet received): 1440062349-25513-3-git-send-email-leilk.liu-NuS5LvNUpcJWk0Htik3J/[email protected]
Applied "spi: medaitek: revise quirks compatibility style" to the spi tree
The patch
spi: medaitek: revise quirks compatibility style
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
af57937e862370c14b7d71d15d969593ffca1ba8Mon Sep 17 00:00:00 2001
From: Leilk Liu <leilk.liu-NuS5LvNUpcJWk0Htik3J/[email protected]>
Date: Thu, 20 Aug 2015 17:19:07 +0800
Subject: [PATCH] spi: medaitek: revise quirks compatibility style
The quirks are true/false, so define these as bool.
--- drivers/spi/spi-mt65xx.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
drivers/spi/spi-mt65xx.c +7 -18
@@ -71,10 +71,6 @@#define SPI_CMD_FINISH_IE BIT(16)#define SPI_CMD_PAUSE_IE BIT(17) -#define MTK_SPI_QUIRK_PAD_SELECT 1 -/* Must explicitly send dummy Tx bytes to do Rx only transfer */ -#define MTK_SPI_QUIRK_MUST_TX 1 -#define MT8173_SPI_MAX_PAD_SEL 3#define MTK_SPI_IDLE 0
@@ -84,8 +80,9 @@#define MTK_SPI_PACKET_SIZE 1024struct mtk_spi_compatible { -u32 need_pad_sel; -u32 must_tx; +bool need_pad_sel; +/* Must explicitly send dummy Tx bytes to do Rx only transfer */ +bool must_tx; };struct mtk_spi {
@@ -100,19 +97,11 @@ struct mtk_spi {const struct mtk_spi_compatible *dev_comp; }; -static const struct mtk_spi_compatible mt6589_compat = { - .need_pad_sel =0 , - .must_tx =0 , -}; - -static const struct mtk_spi_compatible mt8135_compat = { - .need_pad_sel =0 , - .must_tx =0 , -}; - +static const struct mtk_spi_compatible mt6589_compat; +static const struct mtk_spi_compatible mt8135_compat;static const struct mtk_spi_compatible mt8173_compat = { - .need_pad_sel =MTK_SPI_QUIRK_PAD_SELECT , - .must_tx =MTK_SPI_QUIRK_MUST_TX , + .need_pad_sel = true, + .must_tx = true, };/*
Signature · 6 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/4 spi: mediatek: use BIT() to instead of SPI_CMD_*_OFFSET
In reply to Leilk LiuThis patch removes SPI_CMD_*_OFFSET defines, and uses the BIT(x) defines instead.
--- drivers/spi/spi-mt65xx.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/spi/spi-mt65xx.c +20 -17
@@ -48,15 +48,8 @@#define SPI_CFG1_PACKET_LOOP_MASK 0xff00#define SPI_CFG1_PACKET_LENGTH_MASK 0x3ff0000 -#define SPI_CMD_ACT_OFFSET 0 -#define SPI_CMD_RESUME_OFFSET 1 -#define SPI_CMD_CPHA_OFFSET 8 -#define SPI_CMD_CPOL_OFFSET 9 -#define SPI_CMD_TXMSBF_OFFSET 12 -#define SPI_CMD_RXMSBF_OFFSET 13 -#define SPI_CMD_RX_ENDIAN_OFFSET 14 -#define SPI_CMD_TX_ENDIAN_OFFSET 15 - +#define SPI_CMD_ACT BIT(0) +#define SPI_CMD_RESUME BIT(1)#define SPI_CMD_RST BIT(2)#define SPI_CMD_PAUSE_EN BIT(4)#define SPI_CMD_DEASSERT BIT(5)
@@ -143,9 +136,14 @@ static void mtk_spi_config(struct mtk_spi *mdata, reg_val =readl (mdata->base +SPI_CMD_REG );/* set the mlsbx and mlsbtx */ - reg_val &= ~(SPI_CMD_TXMSBF |SPI_CMD_RXMSBF ); - reg_val |= (chip_config->tx_mlsb <<SPI_CMD_TXMSBF_OFFSET ); - reg_val |= (chip_config->rx_mlsb <<SPI_CMD_RXMSBF_OFFSET ); +if (chip_config->tx_mlsb) + reg_val |=SPI_CMD_TXMSBF ; +else + reg_val &= ~SPI_CMD_TXMSBF ; +if (chip_config->rx_mlsb) + reg_val |=SPI_CMD_RXMSBF ; +else + reg_val &= ~SPI_CMD_RXMSBF ;/* set the tx/rx endian */ #ifdef __LITTLE_ENDIAN
@@ -201,9 +199,14 @@ static int mtk_spi_prepare_message(struct spi_master *master, cpol = spi->mode &SPI_CPOL ?1 :0 ; reg_val =readl (mdata->base +SPI_CMD_REG ); - reg_val &= ~(SPI_CMD_CPHA |SPI_CMD_CPOL ); - reg_val |= (cpha <<SPI_CMD_CPHA_OFFSET ); - reg_val |= (cpol <<SPI_CMD_CPOL_OFFSET ); +if (cpha) + reg_val |=SPI_CMD_CPHA ; +else + reg_val &= ~SPI_CMD_CPHA ; +if (cpol) + reg_val |=SPI_CMD_CPOL ; +else + reg_val &= ~SPI_CMD_CPOL ;writel (reg_val, mdata->base +SPI_CMD_REG ); chip_config = spi->controller_data;
@@ -282,9 +285,9 @@ static void mtk_spi_enable_transfer(struct spi_master *master) cmd =readl (mdata->base +SPI_CMD_REG );if (mdata->state ==MTK_SPI_IDLE ) - cmd |=1 <<SPI_CMD_ACT_OFFSET ; + cmd |=SPI_CMD_ACT ;else - cmd |=1 <<SPI_CMD_RESUME_OFFSET ; + cmd |=SPI_CMD_RESUME ;writel (cmd, mdata->base +SPI_CMD_REG ); }
Signature · 1 line
1.8.1.1.dirty
A message that is not in the archive (sent off-list or not yet received): 1440062349-25513-4-git-send-email-leilk.liu-NuS5LvNUpcJWk0Htik3J/[email protected]
Applied "spi: mediatek: use BIT() to instead of SPI_CMD_*_OFFSET" to the spi tree
The patch
spi: mediatek: use BIT() to instead of SPI_CMD_*_OFFSET
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a71d6ea6d3ec3e8ba4220370f29531903e3bc153Mon Sep 17 00:00:00 2001
From: Leilk Liu <leilk.liu-NuS5LvNUpcJWk0Htik3J/[email protected]>
Date: Thu, 20 Aug 2015 17:19:08 +0800
Subject: [PATCH] spi: mediatek: use BIT() to instead of SPI_CMD_*_OFFSET
This patch removes SPI_CMD_*_OFFSET defines, and uses the BIT(x) defines instead.
--- drivers/spi/spi-mt65xx.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/spi/spi-mt65xx.c +20 -17
@@ -48,15 +48,8 @@#define SPI_CFG1_PACKET_LOOP_MASK 0xff00#define SPI_CFG1_PACKET_LENGTH_MASK 0x3ff0000 -#define SPI_CMD_ACT_OFFSET 0 -#define SPI_CMD_RESUME_OFFSET 1 -#define SPI_CMD_CPHA_OFFSET 8 -#define SPI_CMD_CPOL_OFFSET 9 -#define SPI_CMD_TXMSBF_OFFSET 12 -#define SPI_CMD_RXMSBF_OFFSET 13 -#define SPI_CMD_RX_ENDIAN_OFFSET 14 -#define SPI_CMD_TX_ENDIAN_OFFSET 15 - +#define SPI_CMD_ACT BIT(0) +#define SPI_CMD_RESUME BIT(1)#define SPI_CMD_RST BIT(2)#define SPI_CMD_PAUSE_EN BIT(4)#define SPI_CMD_DEASSERT BIT(5)
@@ -143,9 +136,14 @@ static void mtk_spi_config(struct mtk_spi *mdata, reg_val =readl (mdata->base +SPI_CMD_REG );/* set the mlsbx and mlsbtx */ - reg_val &= ~(SPI_CMD_TXMSBF |SPI_CMD_RXMSBF ); - reg_val |= (chip_config->tx_mlsb <<SPI_CMD_TXMSBF_OFFSET ); - reg_val |= (chip_config->rx_mlsb <<SPI_CMD_RXMSBF_OFFSET ); +if (chip_config->tx_mlsb) + reg_val |=SPI_CMD_TXMSBF ; +else + reg_val &= ~SPI_CMD_TXMSBF ; +if (chip_config->rx_mlsb) + reg_val |=SPI_CMD_RXMSBF ; +else + reg_val &= ~SPI_CMD_RXMSBF ;/* set the tx/rx endian */ #ifdef __LITTLE_ENDIAN
@@ -201,9 +199,14 @@ static int mtk_spi_prepare_message(struct spi_master *master, cpol = spi->mode &SPI_CPOL ?1 :0 ; reg_val =readl (mdata->base +SPI_CMD_REG ); - reg_val &= ~(SPI_CMD_CPHA |SPI_CMD_CPOL ); - reg_val |= (cpha <<SPI_CMD_CPHA_OFFSET ); - reg_val |= (cpol <<SPI_CMD_CPOL_OFFSET ); +if (cpha) + reg_val |=SPI_CMD_CPHA ; +else + reg_val &= ~SPI_CMD_CPHA ; +if (cpol) + reg_val |=SPI_CMD_CPOL ; +else + reg_val &= ~SPI_CMD_CPOL ;writel (reg_val, mdata->base +SPI_CMD_REG ); chip_config = spi->controller_data;
@@ -282,9 +285,9 @@ static void mtk_spi_enable_transfer(struct spi_master *master) cmd =readl (mdata->base +SPI_CMD_REG );if (mdata->state ==MTK_SPI_IDLE ) - cmd |=1 <<SPI_CMD_ACT_OFFSET ; + cmd |=SPI_CMD_ACT ;else - cmd |=1 <<SPI_CMD_RESUME_OFFSET ; + cmd |=SPI_CMD_RESUME ;writel (cmd, mdata->base +SPI_CMD_REG ); }
Signature · 6 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 4/4 spi: mediatek: revise coding style
In reply to Leilk LiuThis patch revises littery coding style according to comments.
--- drivers/spi/spi-mt65xx.c | 52 ++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 22 deletions(-)
drivers/spi/spi-mt65xx.c +30 -22
@@ -16,6 +16,7 @@#include <linux/device.h> #include <linux/err.h> #include <linux/interrupt.h> +#include <linux/io.h> #include <linux/ioport.h> #include <linux/module.h> #include <linux/of.h>
@@ -66,6 +67,8 @@#define MT8173_SPI_MAX_PAD_SEL 3 +#define MTK_SPI_PAUSE_INT_STATUS 0x2 +#define MTK_SPI_IDLE 0#define MTK_SPI_PAUSED 1
@@ -178,7 +181,7 @@ static int mtk_spi_prepare_hardware(struct spi_master *master) trans = list_first_entry(&msg->transfers, struct spi_transfer, transfer_list); -if (trans->cs_change ==0 ) { +if (!trans->cs_change) { mdata->state =MTK_SPI_IDLE ;mtk_spi_reset (mdata); }
@@ -235,8 +238,7 @@ static void mtk_spi_set_cs(struct spi_device *spi, bool enable)static void mtk_spi_prepare_transfer (struct spi_master *master,struct spi_transfer *xfer) { -u32 spi_clk_hz, div, high_time, low_time, holdtime, - setuptime, cs_idletime, reg_val =0 ; +u32 spi_clk_hz, div, sck_time, cs_time, reg_val =0 ;struct mtk_spi *mdata =spi_master_get_devdata (master); spi_clk_hz =clk_get_rate (mdata->spi_clk);
@@ -245,21 +247,18 @@ static void mtk_spi_prepare_transfer(struct spi_master *master,else div =1 ; - high_time = (div +1 ) /2 ; - low_time = (div +1 ) /2 ; - holdtime = (div +1 ) /2 *2 ; - setuptime = (div +1 ) /2 *2 ; - cs_idletime = (div +1 ) /2 *2 ; + sck_time = (div +1 ) /2 ; + cs_time = sck_time *2 ; - reg_val |= (((high_time -1 ) &0xff ) <<SPI_CFG0_SCK_HIGH_OFFSET ); - reg_val |= (((low_time -1 ) &0xff ) <<SPI_CFG0_SCK_LOW_OFFSET ); - reg_val |= (((holdtime -1 ) &0xff ) <<SPI_CFG0_CS_HOLD_OFFSET ); - reg_val |= (((setuptime -1 ) &0xff ) <<SPI_CFG0_CS_SETUP_OFFSET ); + reg_val |= (((sck_time -1 ) &0xff ) <<SPI_CFG0_SCK_HIGH_OFFSET ); + reg_val |= (((sck_time -1 ) &0xff ) <<SPI_CFG0_SCK_LOW_OFFSET ); + reg_val |= (((cs_time -1 ) &0xff ) <<SPI_CFG0_CS_HOLD_OFFSET ); + reg_val |= (((cs_time -1 ) &0xff ) <<SPI_CFG0_CS_SETUP_OFFSET );writel (reg_val, mdata->base +SPI_CFG0_REG ); reg_val =readl (mdata->base +SPI_CFG1_REG ); reg_val &= ~SPI_CFG1_CS_IDLE_MASK ; - reg_val |= (((cs_idletime -1 ) &0xff ) <<SPI_CFG1_CS_IDLE_OFFSET ); + reg_val |= (((cs_time -1 ) &0xff ) <<SPI_CFG1_CS_IDLE_OFFSET );writel (reg_val, mdata->base +SPI_CFG1_REG ); }
@@ -268,11 +267,11 @@ static void mtk_spi_setup_packet(struct spi_master *master)u32 packet_size, packet_loop, reg_val;struct mtk_spi *mdata =spi_master_get_devdata (master); - packet_size =min_t (unsigned, mdata->xfer_len,MTK_SPI_PACKET_SIZE ); + packet_size =min_t (u32, mdata->xfer_len,MTK_SPI_PACKET_SIZE ); packet_loop = mdata->xfer_len / packet_size; reg_val =readl (mdata->base +SPI_CFG1_REG ); - reg_val &= ~(SPI_CFG1_PACKET_LENGTH_MASK +SPI_CFG1_PACKET_LOOP_MASK ); + reg_val &= ~(SPI_CFG1_PACKET_LENGTH_MASK |SPI_CFG1_PACKET_LOOP_MASK ); reg_val |= (packet_size -1 ) <<SPI_CFG1_PACKET_LENGTH_OFFSET ; reg_val |= (packet_loop -1 ) <<SPI_CFG1_PACKET_LOOP_OFFSET ;writel (reg_val, mdata->base +SPI_CFG1_REG );
@@ -280,7 +279,7 @@ static void mtk_spi_setup_packet(struct spi_master *master)static void mtk_spi_enable_transfer (struct spi_master *master) { -int cmd; +u32 cmd;struct mtk_spi *mdata =spi_master_get_devdata (master); cmd =readl (mdata->base +SPI_CMD_REG );
@@ -291,9 +290,9 @@ static void mtk_spi_enable_transfer(struct spi_master *master)writel (cmd, mdata->base +SPI_CMD_REG ); } -static int mtk_spi_get_mult_delta (int xfer_len) +static int mtk_spi_get_mult_delta (u32 xfer_len) { -int mult_delta; +u32 mult_delta;if (xfer_len >MTK_SPI_PACKET_SIZE ) mult_delta = xfer_len %MTK_SPI_PACKET_SIZE ;
@@ -434,7 +433,7 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id)struct spi_transfer *trans = mdata->cur_transfer; reg_val =readl (mdata->base +SPI_STATUS0_REG ); -if (reg_val &0x2 ) +if (reg_val &MTK_SPI_PAUSE_INT_STATUS ) mdata->state =MTK_SPI_PAUSED ;else mdata->state =MTK_SPI_IDLE ;
@@ -497,7 +496,7 @@ static int mtk_spi_probe(struct platform_device *pdev)struct mtk_spi *mdata;const struct of_device_id *of_id;struct resource *res; -int irq, ret; +int irq, ret; master =spi_alloc_master (&pdev->dev,sizeof (*mdata));if (!master) {
@@ -662,8 +661,10 @@ static int mtk_spi_resume(struct device *dev)if (!pm_runtime_suspended (dev)) { ret =clk_prepare_enable (mdata->spi_clk); -if (ret <0 ) +if (ret <0 ) { +dev_err (dev,"failed to enable spi_clk (%d)\n" , ret);return ret; + } } ret =spi_master_resume (master);
@@ -689,8 +690,15 @@ static int mtk_spi_runtime_resume(struct device *dev) {struct spi_master *master =dev_get_drvdata (dev);struct mtk_spi *mdata =spi_master_get_devdata (master); +int ret; -return clk_prepare_enable (mdata->spi_clk); + ret =clk_prepare_enable (mdata->spi_clk); +if (ret <0 ) { +dev_err (dev,"failed to enable spi_clk (%d)\n" , ret); +return ret; + } + +return 0 ; }#endif /* CONFIG_PM */
Signature · 1 line
1.8.1.1.dirty
Mark Brown
maintainerRe: [PATCH v2 4/4] spi: mediatek: revise coding style
Quoted 1 line · Leilk Liu
This patch revises littery coding style according to comments.
I can't understand this commit log, sorry - what are the comments that are being addressed?
drivers/spi/spi-mt65xx.c static void mtk_spi_prepare_transfer(struct spi_master *master, · line 256
Quoted 8 lines
drivers/spi/spi-mt65xx.c +4
-4- reg_val |= (((high_time -1 ) &0xff ) <<SPI_CFG0_SCK_HIGH_OFFSET ); - reg_val |= (((low_time -1 ) &0xff ) <<SPI_CFG0_SCK_LOW_OFFSET ); - reg_val |= (((holdtime -1 ) &0xff ) <<SPI_CFG0_CS_HOLD_OFFSET ); - reg_val |= (((setuptime -1 ) &0xff ) <<SPI_CFG0_CS_SETUP_OFFSET ); + reg_val |= (((sck_time -1 ) &0xff ) <<SPI_CFG0_SCK_HIGH_OFFSET ); + reg_val |= (((sck_time -1 ) &0xff ) <<SPI_CFG0_SCK_LOW_OFFSET ); + reg_val |= (((cs_time -1 ) &0xff ) <<SPI_CFG0_CS_HOLD_OFFSET ); + reg_val |= (((cs_time -1 ) &0xff ) <<SPI_CFG0_CS_SETUP_OFFSET );
This isn't a coding style change this is (I think) renaming a bunch of
variables for some reason.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150820/52c592c0/attachment-0001.sig>