dma: mxs-dma: use global stmp_device functionality
Subsystems (7)
PATCH v2 1/5 dma: mxs-dma: use global stmp_device functionality
From: Dong Aisheng <[email protected]>
This can get rid of the mach-dependency.
---
This patch depends on Wolfram's
[PATCH V2 1/3] lib: add support for stmp-style devices
http://www.spinics.net/lists/arm-kernel/msg166232.html
which is still not in mainline.
--- drivers/dma/Kconfig | 1 + drivers/dma/mxs-dma.c | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/dma/Kconfig +1 -0
@@ -238,6 +238,7 @@ config IMX_DMA config MXS_DMA bool "MXS DMA support" depends on SOC_IMX23 || SOC_IMX28 + select STMP_DEVICE select DMA_ENGINE help Support the MXS DMA engine. This engine including APBH-DMA
drivers/dma/mxs-dma.c +13 -14
@@ -23,10 +23,9 @@#include <linux/dmaengine.h> #include <linux/delay.h> #include <linux/fsl/mxs-dma.h> +#include <linux/stmp_device.h> #include <asm/irq.h> -#include <mach/mxs.h> -#include <mach/common.h> #include "dmaengine.h"
@@ -138,10 +137,10 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan)if (dma_is_apbh () &&apbh_is_old ())writel (1 << (chan_id +BP_APBH_CTRL0_RESET_CHANNEL ), - mxs_dma->base +HW_APBHX_CTRL0 +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CTRL0 +STMP_OFFSET_REG_SET );else writel (1 << (chan_id +BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL ), - mxs_dma->base +HW_APBHX_CHANNEL_CTRL +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CHANNEL_CTRL +STMP_OFFSET_REG_SET ); }static void mxs_dma_enable_chan (struct mxs_dma_chan *mxs_chan)
@@ -170,10 +169,10 @@ static void mxs_dma_pause_chan(struct mxs_dma_chan *mxs_chan)/* freeze the channel */ if (dma_is_apbh () &&apbh_is_old ())writel (1 << chan_id, - mxs_dma->base +HW_APBHX_CTRL0 +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CTRL0 +STMP_OFFSET_REG_SET );else writel (1 << chan_id, - mxs_dma->base +HW_APBHX_CHANNEL_CTRL +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CHANNEL_CTRL +STMP_OFFSET_REG_SET ); mxs_chan->status =DMA_PAUSED ; }
@@ -186,10 +185,10 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan)/* unfreeze the channel */ if (dma_is_apbh () &&apbh_is_old ())writel (1 << chan_id, - mxs_dma->base +HW_APBHX_CTRL0 +MXS_CLR_ADDR ); + mxs_dma->base +HW_APBHX_CTRL0 +STMP_OFFSET_REG_CLR );else writel (1 << chan_id, - mxs_dma->base +HW_APBHX_CHANNEL_CTRL +MXS_CLR_ADDR ); + mxs_dma->base +HW_APBHX_CHANNEL_CTRL +STMP_OFFSET_REG_CLR ); mxs_chan->status =DMA_IN_PROGRESS ; }
@@ -220,11 +219,11 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)/* completion status */ stat1 =readl (mxs_dma->base +HW_APBHX_CTRL1 ); stat1 &=MXS_DMA_CHANNELS_MASK ; -writel (stat1, mxs_dma->base +HW_APBHX_CTRL1 +MXS_CLR_ADDR ); +writel (stat1, mxs_dma->base +HW_APBHX_CTRL1 +STMP_OFFSET_REG_CLR );/* error status */ stat2 =readl (mxs_dma->base +HW_APBHX_CTRL2 ); -writel (stat2, mxs_dma->base +HW_APBHX_CTRL2 +MXS_CLR_ADDR ); +writel (stat2, mxs_dma->base +HW_APBHX_CTRL2 +STMP_OFFSET_REG_CLR );/* * When both completion and error of termination bits set at the
@@ -567,7 +566,7 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)if (ret)return ret; - ret =mxs_reset_block (mxs_dma->base); + ret =stmp_reset_block (mxs_dma->base);if (ret) goto err_out;
@@ -580,14 +579,14 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)/* enable apbh burst */ if (dma_is_apbh ()) {writel (BM_APBH_CTRL0_APB_BURST_EN , - mxs_dma->base +HW_APBHX_CTRL0 +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CTRL0 +STMP_OFFSET_REG_SET );writel (BM_APBH_CTRL0_APB_BURST8_EN , - mxs_dma->base +HW_APBHX_CTRL0 +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CTRL0 +STMP_OFFSET_REG_SET ); }/* enable irq for all the channels */ writel (MXS_DMA_CHANNELS_MASK <<MXS_DMA_CHANNELS , - mxs_dma->base +HW_APBHX_CTRL1 +MXS_SET_ADDR ); + mxs_dma->base +HW_APBHX_CTRL1 +STMP_OFFSET_REG_SET ); err_out:clk_disable_unprepare (mxs_dma->clk);
Signature · 1 line
1.7.0.4
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
From: Dong Aisheng <[email protected]>
Rewrite mxs_dma_is_apbh and mxs_dma_is_apbx in order to support other SoCs like imx6q and reform the platform_device_id for the better further dt support.
---
ChangeLog v1->v2:
* remove using mxs_dma->version
* other minor fixes suggested by Shawn.
--- arch/arm/mach-mxs/clock-mx23.c | 4 +- arch/arm/mach-mxs/clock-mx28.c | 4 +- arch/arm/mach-mxs/devices/platform-dma.c | 14 ++-- drivers/dma/mxs-dma.c | 115 ++++++++++++++++++++--------- include/linux/fsl/mxs-dma.h | 12 +--- 5 files changed, 93 insertions(+), 56 deletions(-)
arch/arm/mach-mxs/clock-mx23.c +2 -2
@@ -427,8 +427,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("duart", NULL, uart_clk) _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk) _REGISTER_CLOCK("rtc", NULL, rtc_clk) - _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk) - _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) + _REGISTER_CLOCK("imx23-dma-apbh", NULL, hbus_clk) + _REGISTER_CLOCK("imx23-dma-apbx", NULL, xbus_clk) _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp_clk) _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp_clk)_REGISTER_CLOCK (NULL ,"usb" , usb_clk)
arch/arm/mach-mxs/clock-mx28.c +2 -2
@@ -625,8 +625,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("mxs-auart.4", NULL, uart_clk) _REGISTER_CLOCK("rtc", NULL, rtc_clk) _REGISTER_CLOCK("pll2", NULL, pll2_clk) - _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk) - _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) + _REGISTER_CLOCK("imx28-dma-apbh", NULL, hbus_clk) + _REGISTER_CLOCK("imx28-dma-apbx", NULL, xbus_clk) _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk) _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk)_REGISTER_CLOCK ("mxs-mmc.2" ,NULL , ssp2_clk)
arch/arm/mach-mxs/devices/platform-dma.c +8 -6
@@ -32,17 +32,19 @@ static struct platform_device *__init mxs_add_dma(const char *devid,static int __init mxs_add_mxs_dma (void ) { -char *apbh ="mxs-dma-apbh" ; -char *apbx ="mxs-dma-apbx" ; +char *mx23_apbh ="imx23-dma-apbh" ; +char *mx23_apbx ="imx23-dma-apbx" ; +char *mx28_apbh ="imx28-dma-apbh" ; +char *mx28_apbx ="imx28-dma-apbx" ;if (cpu_is_mx23 ()) { -mxs_add_dma (apbh,MX23_APBH_DMA_BASE_ADDR ); -mxs_add_dma (apbx,MX23_APBX_DMA_BASE_ADDR ); +mxs_add_dma (mx23_apbh,MX23_APBH_DMA_BASE_ADDR ); +mxs_add_dma (mx23_apbx,MX23_APBX_DMA_BASE_ADDR ); }if (cpu_is_mx28 ()) { -mxs_add_dma (apbh,MX28_APBH_DMA_BASE_ADDR ); -mxs_add_dma (apbx,MX28_APBX_DMA_BASE_ADDR ); +mxs_add_dma (mx28_apbh,MX28_APBH_DMA_BASE_ADDR ); +mxs_add_dma (mx28_apbx,MX28_APBX_DMA_BASE_ADDR ); }return 0 ;
drivers/dma/mxs-dma.c +79 -36
174 lines not on this page · raw message
include/linux/fsl/mxs-dma.h +2 -10
@@ -15,14 +15,6 @@ struct mxs_dma_data { int chan_irq; }; -static inline int mxs_dma_is_apbh (struct dma_chan *chan) -{ -return !strcmp (dev_name (chan->device->dev),"mxs-dma-apbh" ); -} - -static inline int mxs_dma_is_apbx (struct dma_chan *chan) -{ -return !strcmp (dev_name (chan->device->dev),"mxs-dma-apbx" ); -} - +extern int mxs_dma_is_apbh (struct dma_chan *chan); +extern int mxs_dma_is_apbx (struct dma_chan *chan);#endif /* __MACH_MXS_DMA_H__ */
Signature · 1 line
1.7.0.4
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Dear Dong Aisheng,
Quoted 61 lines
From: Dong Aisheng <[email protected]>
Rewrite
mxs_dma_is_apbhandmxs_dma_is_apbxin order to support other SoCs like imx6q and reform theplatform_device_idfor the better further dt support.Cc Vinod Koul <[email protected]>Cc Dan Williams <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Huang Shijie <[email protected]>Reviewed-by Marek Vasut <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
ChangeLogv1->v2:
* remove usingmxs_dma->version
* other minor fixes suggested by Shawn.--- arch/arm/mach-mxs/clock-mx23.c | 4 +- arch/arm/mach-mxs/clock-mx28.c | 4 +- arch/arm/mach-mxs/devices/platform-dma.c | 14 ++-- drivers/dma/mxs-dma.c | 115 ++++++++++++++++++++--------- include/linux/fsl/mxs-dma.h | 12 +--- 5 files changed, 93 insertions(+), 56 deletions(-)(quoted diff) +0
-0
b/arch/arm/mach-mxs/clock-mx23.cindex e3ac52c..1e67b85 100644arch/arm/mach-mxs/clock-mx23.c +2
-2@@ -427,8 +427,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("duart", NULL, uart_clk) _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk) _REGISTER_CLOCK("rtc", NULL, rtc_clk) - _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk) - _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) + _REGISTER_CLOCK("imx23-dma-apbh", NULL, hbus_clk) + _REGISTER_CLOCK("imx23-dma-apbx", NULL, xbus_clk) _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp_clk) _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp_clk)_REGISTER_CLOCK (NULL ,"usb" , usb_clk)(quoted diff) +0
-0
b/arch/arm/mach-mxs/clock-mx28.cindex 1867a17..cca2cf7 100644arch/arm/mach-mxs/clock-mx28.c +2
-2@@ -625,8 +625,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("mxs-auart.4", NULL, uart_clk) _REGISTER_CLOCK("rtc", NULL, rtc_clk) _REGISTER_CLOCK("pll2", NULL, pll2_clk) - _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk) - _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) + _REGISTER_CLOCK("imx28-dma-apbh", NULL, hbus_clk) + _REGISTER_CLOCK("imx28-dma-apbx", NULL, xbus_clk) _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk) _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk)_REGISTER_CLOCK ("mxs-mmc.2" ,NULL , ssp2_clk)(quoted diff) +0
-0
b/arch/arm/mach-mxs/devices/platform-dma.cindex 6a0202b..aff4813 100644
arch/arm/mach-mxs/devices/platform-dma.c static struct platform_device *__init mxs_add_dma(const · line 39
Quoted 10 lines
arch/arm/mach-mxs/devices/platform-dma.c +4
-2@@ -32,17 +32,19 @@ static struct platform_device *__init mxs_add_dma(constchar *devid, static int __init mxs_add_mxs_dma(void) { - char *apbh = "mxs-dma-apbh"; -char *apbx ="mxs-dma-apbx" ; + char *mx23_apbh = "imx23-dma-apbh"; +char *mx23_apbx ="imx23-dma-apbx" ; +char *mx28_apbh ="imx28-dma-apbh" ; +char *mx28_apbx ="imx28-dma-apbx" ;
Wild guess ... but const char * won't hurt here ?
Quoted 36 lines
arch/arm/mach-mxs/devices/platform-dma.c +4
-4if (cpu_is_mx23 ()) { -mxs_add_dma (apbh,MX23_APBH_DMA_BASE_ADDR ); -mxs_add_dma (apbx,MX23_APBX_DMA_BASE_ADDR ); +mxs_add_dma (mx23_apbh,MX23_APBH_DMA_BASE_ADDR ); +mxs_add_dma (mx23_apbx,MX23_APBX_DMA_BASE_ADDR ); }if (cpu_is_mx28 ()) { -mxs_add_dma (apbh,MX28_APBH_DMA_BASE_ADDR ); -mxs_add_dma (apbx,MX28_APBX_DMA_BASE_ADDR ); +mxs_add_dma (mx28_apbh,MX28_APBH_DMA_BASE_ADDR ); +mxs_add_dma (mx28_apbx,MX28_APBX_DMA_BASE_ADDR ); }return 0 ;drivers/dma/mxs-dma.c +2
-6@@ -35,12 +35,8 @@* dma can program the controller registers of peripheral devices. */ -#define MXS_DMA_APBH 0 -#define MXS_DMA_APBX 1 -#define dma_is_apbh () (mxs_dma->dev_id == MXS_DMA_APBH) - -#define APBH_VERSION_LATEST 3 -#define apbh_is_old () (mxs_dma->version < APBH_VERSION_LATEST) +#define dma_is_apbh () (mxs_dma->type == MXS_DMA_APBH) +#define apbh_is_old () (mxs_dma->dev_id == IMX23_DMA)#define HW_APBHX_CTRL0 0x000#define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)
drivers/dma/mxs-dma.c line 53
Quoted 4 lines
drivers/dma/mxs-dma.c +0
-1@@ -50,9 +46,6 @@#define HW_APBHX_CTRL2 0x020#define HW_APBHX_CHANNEL_CTRL 0x030#define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16 -#define HW_APBH_VERSION (cpu_is_mx23() ? 0x3f0 :
0x800)
Quoted 69 lines
drivers/dma/mxs-dma.c +50
-4-#define HW_APBX_VERSION 0x800 -#define BP_APBHX_VERSION_MAJOR 24#define HW_APBHX_CHn_NXTCMDAR (n) \ (((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)#define HW_APBHX_CHn_SEMA (n) \@@ -120,9 +113,19 @@ struct mxs_dma_chan {#define MXS_DMA_CHANNELS 16#define MXS_DMA_CHANNELS_MASK 0xffff +enum mxs_dma_devtype { +MXS_DMA_APBH , +MXS_DMA_APBX , +}; + +enum mxs_dma_id { +IMX23_DMA , +IMX28_DMA , +}; +struct mxs_dma_engine { -int dev_id; -unsigned int version; +enum mxs_dma_id dev_id; +enum mxs_dma_devtype type;void __iomem *base;struct clk *clk;struct dma_device dma_device;@@ -130,6 +133,66 @@ struct mxs_dma_engine {struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS ]; }; +struct mxs_dma_type { +enum mxs_dma_id id; +enum mxs_dma_devtype type; +}; + +static struct mxs_dma_type mxs_dma_types[] = { + { + .id =IMX23_DMA , + .type =MXS_DMA_APBH , + }, { + .id =IMX23_DMA , + .type =MXS_DMA_APBX , + }, { + .id =IMX28_DMA , + .type =MXS_DMA_APBH , + }, { + .id =IMX28_DMA , + .type =MXS_DMA_APBX , + } +}; + +static struct platform_device_id mxs_dma_ids[] = { + { + .name ="imx23-dma-apbh" , + .driver_data = (kernel_ulong_t) &mxs_dma_types[0 ], + }, { + .name ="imx23-dma-apbx" , + .driver_data = (kernel_ulong_t) &mxs_dma_types[1 ], + }, { + .name ="imx28-dma-apbh" , + .driver_data = (kernel_ulong_t) &mxs_dma_types[2 ], + }, { + .name ="imx28-dma-apbx" , + .driver_data = (kernel_ulong_t) &mxs_dma_types[3 ], + }, { +/* end of list */ + } +};
drivers/dma/mxs-dma.c struct mxs_dma_engine { · line 183
Quoted 10 lines
drivers/dma/mxs-dma.c +10
-0+ +static struct mxs_dma_chan *to_mxs_dma_chan (struct dma_chan *chan) +{ + return container_of(chan, struct mxs_dma_chan, chan); +} + +int mxs_dma_is_apbh (struct dma_chan *chan) +{ +struct mxs_dma_chan *mxs_chan =to_mxs_dma_chan (chan); +struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
Do you need the above here ? :)
drivers/dma/mxs-dma.c struct mxs_dma_engine { · line 192
Quoted 9 lines
drivers/dma/mxs-dma.c +9
-0+ +return dma_is_apbh (); +} + +int mxs_dma_is_apbx (struct dma_chan *chan) +{ +struct mxs_dma_chan *mxs_chan =to_mxs_dma_chan (chan); +struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; +
Dtto ?
Quoted 96 lines
drivers/dma/mxs-dma.c +8
-25+return !dma_is_apbh (); +} +static void mxs_dma_reset_chan (struct mxs_dma_chan *mxs_chan) {struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;@@ -193,11 +256,6 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan) mxs_chan->status = DMA_IN_PROGRESS; } -static struct mxs_dma_chan *to_mxs_dma_chan (struct dma_chan *chan) -{ - return container_of(chan, struct mxs_dma_chan, chan); -} -static dma_cookie_t mxs_dma_tx_submit (struct dma_async_tx_descriptor *tx) {return dma_cookie_assign (tx);@@ -570,12 +628,6 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) if (ret) goto err_out; -/* only major version matters */ - mxs_dma->version =readl (mxs_dma->base + - ((mxs_dma->dev_id ==MXS_DMA_APBX ) ? -HW_APBX_VERSION :HW_APBH_VERSION )) >> -BP_APBHX_VERSION_MAJOR ; -/* enable apbh burst */ if (dma_is_apbh ()) { writel(BM_APBH_CTRL0_APB_BURST_EN,@@ -597,6 +649,8 @@ static int __init mxs_dma_probe(struct platform_device *pdev) {const struct platform_device_id *id_entry =platform_get_device_id (pdev); +const struct mxs_dma_type *dma_type = + (struct mxs_dma_type *)id_entry->driver_data;struct mxs_dma_engine *mxs_dma;struct resource *iores;int ret, i;@@ -605,7 +659,8 @@ static int __init mxs_dma_probe(struct platform_device *pdev) if (!mxs_dma)return -ENOMEM ; - mxs_dma->dev_id = id_entry->driver_data; + mxs_dma->dev_id = dma_type->id; + mxs_dma->type = dma_type->type; iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -688,23 +743,11 @@ err_request_region:return ret; } -static struct platform_device_id mxs_dma_type[] = { - { - .name ="mxs-dma-apbh" , - .driver_data =MXS_DMA_APBH , - }, { - .name ="mxs-dma-apbx" , - .driver_data =MXS_DMA_APBX , - }, { -/* end of list */ - } -}; -static struct platform_driver mxs_dma_driver = { .driver = { .name ="mxs-dma" , }, - .id_table = mxs_dma_type, + .id_table = mxs_dma_ids, };static int __init mxs_dma_module_init (void )include/linux/fsl/mxs-dma.h +2
-10@@ -15,14 +15,6 @@ struct mxs_dma_data { int chan_irq; }; -static inline int mxs_dma_is_apbh (struct dma_chan *chan) -{ -return !strcmp (dev_name (chan->device->dev),"mxs-dma-apbh" ); -} - -static inline int mxs_dma_is_apbx (struct dma_chan *chan) -{ -return !strcmp (dev_name (chan->device->dev),"mxs-dma-apbx" ); -} - +extern int mxs_dma_is_apbh (struct dma_chan *chan); +extern int mxs_dma_is_apbx (struct dma_chan *chan);#endif /* __MACH_MXS_DMA_H__ */
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Quoted 11 lines · Marek Vasut
arch/arm/mach-mxs/devices/platform-dma.c static struct platform_device *__init mxs_add_dma(const char *devid, · line 38
Quoted 8 lines
static int
__initmxs_add_mxs_dma(void)
{arch/arm/mach-mxs/devices/platform-dma.c +4
-2-char *apbh ="mxs-dma-apbh" ; -char *apbx ="mxs-dma-apbx" ; +char *mx23_apbh ="imx23-dma-apbh" ; +char *mx23_apbx ="imx23-dma-apbx" ; +char *mx28_apbh ="imx28-dma-apbh" ; +char *mx28_apbx ="imx28-dma-apbx" ;Wild guess ... but const char * won't hurt here ?
Right. I guess it just followed how the existing code looks like. Considering this whole function will be removed patch #4, it should not be a big problem, I guess.
Quoted 9 lines
Quoted 9 lines
drivers/dma/mxs-dma.c +2
-6-#define MXS_DMA_APBH 0 -#define MXS_DMA_APBX 1 -#define dma_is_apbh () (mxs_dma->dev_id == MXS_DMA_APBH) - -#define APBH_VERSION_LATEST 3 -#define apbh_is_old () (mxs_dma->version < APBH_VERSION_LATEST) +#define dma_is_apbh () (mxs_dma->type == MXS_DMA_APBH) +#define apbh_is_old () (mxs_dma->dev_id == IMX23_DMA)
...
Quoted 7 lines
drivers/dma/mxs-dma.c struct mxs_dma_engine { · line 183
Quoted 4 lines
drivers/dma/mxs-dma.c +4
-0+int mxs_dma_is_apbh (struct dma_chan *chan) +{ +struct mxs_dma_chan *mxs_chan =to_mxs_dma_chan (chan); +struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;Do you need the above here ? :)
I have to confess it's my bad. I made the code hard to read when I created the driver. The dma_is_apbh() should really takes mxs_dma as a parameter than hiding it in the macro.
While I agree this is something should be improved, it may be better to do it in another patch?
Quoted 3 lines
Quoted 3 lines
drivers/dma/mxs-dma.c +3
-0+ +return dma_is_apbh (); +}
Signature · 2 lines
Regards, Shawn
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Dear Shawn Guo,
Quoted 13 lines · Marek Vasut
Quoted 11 lines
arch/arm/mach-mxs/devices/platform-dma.c static struct platform_device *__init mxs_add_dma(const char *devid, · line 38
Quoted 9 lines
static int
__initmxs_add_mxs_dma(void)
{arch/arm/mach-mxs/devices/platform-dma.c +4
-2-char *apbh ="mxs-dma-apbh" ; -char *apbx ="mxs-dma-apbx" ; +char *mx23_apbh ="imx23-dma-apbh" ; +char *mx23_apbx ="imx23-dma-apbx" ; +char *mx28_apbh ="imx28-dma-apbh" ; +char *mx28_apbx ="imx28-dma-apbx" ;Wild guess ... but const char * won't hurt here ?
Quoted 3 lines
Right. I guess it just followed how the existing code looks like. Considering this whole function will be removed patch #4, it should not be a big problem, I guess.
Can't the patches be reordered then to avoid adding this altogether?
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
drivers/dma/mxs-dma.c +2
-6-#define MXS_DMA_APBH 0 -#define MXS_DMA_APBX 1 -#define dma_is_apbh () (mxs_dma->dev_id == MXS_DMA_APBH) - -#define APBH_VERSION_LATEST 3 -#define apbh_is_old () (mxs_dma->version < APBH_VERSION_LATEST) +#define dma_is_apbh () (mxs_dma->type == MXS_DMA_APBH) +#define apbh_is_old () (mxs_dma->dev_id == IMX23_DMA)...
Quoted 6 lines
drivers/dma/mxs-dma.c struct mxs_dma_engine { · line 183
Quoted 4 lines
drivers/dma/mxs-dma.c +4
-0+int mxs_dma_is_apbh (struct dma_chan *chan) +{ +struct mxs_dma_chan *mxs_chan =to_mxs_dma_chan (chan); +struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;Do you need the above here ? :)
Quoted 6 lines
I have to confess it's my bad. I made the code hard to read when I created the driver. The
dma_is_apbh()should really takesmxs_dmaas a parameter than hiding it in the macro.While I agree this is something should be improved, it may be better to do it in another patch?
You don't have to add dead code in this patch and re-add it when needed. Or fix the macro to take the parameter then, though I don't understand why you'd want to take it and then hide it.
Quoted 3 lines
Quoted 3 lines
drivers/dma/mxs-dma.c struct mxs_dma_engine { · line 186
Quoted 3 lines
drivers/dma/mxs-dma.c +3
-0+ +return dma_is_apbh (); +}
Best regards,
Marek Vasut
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Quoted 2 lines · Marek Vasut
Can't the patches be reordered then to avoid adding this altogether?
Maybe. But I do not think it's really worth the effort.
Quoted 4 lines
You don't have to add dead code in this patch and re-add it when needed. Or fix the macro to take the parameter then, though I don't understand why you'd want to take it and then hide it.
I do not completely understand the comment. My point is the problem is in the existing code. It's not introduced by Dong's patch. The problem should be fixed in another patch, and we do not want to do several things in one patch.
Regards,
Shawn
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Dear Shawn Guo,
Quoted 5 lines · Marek Vasut
Quoted 1 line
Can't the patches be reordered then to avoid adding this altogether?
Maybe. But I do not think it's really worth the effort.
Quoted 8 lines
Quoted 3 lines
You don't have to add dead code in this patch and re-add it when needed. Or fix the macro to take the parameter then, though I don't understand why you'd want to take it and then hide it.
I do not completely understand the comment. My point is the problem is in the existing code. It's not introduced by Dong's patch. The problem should be fixed in another patch, and we do not want to do several things in one patch.
Then order such a patch before Dong's series then? It'd all be clear, without compromises.
Quoted 3 lines
Regards,
Shawn
Best regards,
Marek Vasut
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Quoted 11 lines · Marek Vasut
Dear Shawn Guo,
Quoted 9 lines · Marek Vasut
Quoted 1 line
Can't the patches be reordered then to avoid adding this altogether?
Maybe. But I do not think it's really worth the effort.
Quoted 3 lines
You don't have to add dead code in this patch and re-add it when needed. Or fix the macro to take the parameter then, though I don't understand why you'd want to take it and then hide it.
Quoted 8 lines
Quoted 4 lines
I do not completely understand the comment. My point is the problem is in the existing code. It's not introduced by Dong's patch. The problem should be fixed in another patch, and we do not want to do several things in one patch.
Then order such a patch before Dong's series then? It'd all be clear, without compromises.
Hmm, although not a big issue, but i can re-oder it to make most people happy with the patch.
Thanks
Regards
Dong Aisheng
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Quoted 3 lines · Dong Aisheng
Hmm, although not a big issue, but i can re-oder it to make most people happy with the patch.
I will take care of it, since I will need to rebase the series on mxs-common-clk series anyway. Hopefully, I can get it out today.
Regard,
Shawn
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Dear Shawn Guo,
Quoted 6 lines · Dong Aisheng
Quoted 2 lines
Hmm, although not a big issue, but i can re-oder it to make most people happy with the patch.
I will take care of it, since I will need to rebase the series on mxs-common-clk series anyway. Hopefully, I can get it out today.
Why do I get the feeling I'm the bad guy here ? :-)
Quoted 3 lines
Regard,
Shawn
Best regards,
Marek Vasut
PATCH v2 2/5 dma: mxs-dma: make platform_device_id more generic
Quoted 2 lines · Marek Vasut
Why do I get the feeling I'm the bad guy here ? :-)
The "bad" buy is asking for good code, so welcome :)
Regards,
Shawn
PATCH v2 3/5 dma: mxs-dma: add device tree probe support
In reply to Dong AishengFrom: Dong Aisheng <[email protected]>
---
ChangeLog v1->v2:
* remove #ifdef CONFIG_OF for mxs_dma_dt_ids based on Shawn's suggestion.
--- .../devicetree/bindings/dma/fsl-mxs-dma.txt | 19 +++++++++++++ drivers/dma/mxs-dma.c | 29 ++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt new file +19 -0
@@ -0,0 +1,19 @@ +* Freescale MXS DMA + +Required properties: +- compatible : Should be "fsl,<chip>-dma-apbh" or "fsl,<chip>-dma-apbx" +- reg : Should contain registers location and length + +Supported chips: +imx23, imx28. + +Examples: +dma-apbh at 80004000 { + compatible = "fsl,imx28-dma-apbh"; + reg = <0x80004000 2000>; +}; + +dma-apbx at 80024000 { + compatible = "fsl,imx28-dma-apbx"; + reg = <0x80024000 2000>; +};
drivers/dma/mxs-dma.c +24 -5
@@ -22,8 +22,11 @@#include <linux/platform_device.h> #include <linux/dmaengine.h> #include <linux/delay.h> +#include <linux/module.h> #include <linux/fsl/mxs-dma.h> #include <linux/stmp_device.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <asm/irq.h>
@@ -172,6 +175,15 @@ static struct platform_device_id mxs_dma_ids[] = { } }; +static const struct of_device_id mxs_dma_dt_ids[] = { + { .compatible ="fsl,imx23-dma-apbh" , .data = &mxs_dma_ids[0 ], }, + { .compatible ="fsl,imx23-dma-apbx" , .data = &mxs_dma_ids[1 ], }, + { .compatible ="fsl,imx28-dma-apbh" , .data = &mxs_dma_ids[2 ], }, + { .compatible ="fsl,imx28-dma-apbx" , .data = &mxs_dma_ids[3 ], }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, mxs_dma_dt_ids); +static struct mxs_dma_chan *to_mxs_dma_chan (struct dma_chan *chan) { return container_of(chan, struct mxs_dma_chan, chan);
@@ -647,10 +659,9 @@ err_out:static int __init mxs_dma_probe (struct platform_device *pdev) { -const struct platform_device_id *id_entry = -platform_get_device_id (pdev); -const struct mxs_dma_type *dma_type = - (struct mxs_dma_type *)id_entry->driver_data; +const struct platform_device_id *id_entry; +const struct of_device_id *of_id; +const struct mxs_dma_type *dma_type;struct mxs_dma_engine *mxs_dma;struct resource *iores;int ret, i;
@@ -659,8 +670,15 @@ static int __init mxs_dma_probe(struct platform_device *pdev)if (!mxs_dma)return -ENOMEM ; - mxs_dma->dev_id = dma_type->id; + of_id =of_match_device (mxs_dma_dt_ids, &pdev->dev); +if (of_id) + id_entry = of_id->data; +else + id_entry =platform_get_device_id (pdev); + + dma_type = (struct mxs_dma_type *)id_entry->driver_data; mxs_dma->type = dma_type->type; + mxs_dma->dev_id = dma_type->id; iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -746,6 +764,7 @@ err_request_region:static struct platform_driver mxs_dma_driver = { .driver = { .name ="mxs-dma" , + .of_match_table = mxs_dma_dt_ids, }, .id_table = mxs_dma_ids, };
Signature · 1 line
1.7.0.4
PATCH v2 4/5 ARM: mxs: do not add dma device by default
In reply to Dong AishengFrom: Dong Aisheng <[email protected]>
This will cause conflict when dt is enabled. So let each platform add dma devices respectively.
---
ChangeLog v2->v3:
* introduce mx23/mx28_soc_init()
ChangeLog v1->v2:
* Add the missed mx28_add_dma() for mx28evk.c.
--- arch/arm/mach-mxs/devices/platform-dma.c | 23 +---------------------- arch/arm/mach-mxs/include/mach/common.h | 4 ++++ arch/arm/mach-mxs/mach-apx4devkit.c | 2 ++ arch/arm/mach-mxs/mach-m28evk.c | 2 ++ arch/arm/mach-mxs/mach-mx23evk.c | 2 ++ arch/arm/mach-mxs/mach-mx28evk.c | 2 ++ arch/arm/mach-mxs/mach-stmp378x_devb.c | 2 ++ arch/arm/mach-mxs/mach-tx28.c | 2 ++ arch/arm/mach-mxs/mm.c | 12 ++++++++++++ 9 files changed, 29 insertions(+), 22 deletions(-)
arch/arm/mach-mxs/devices/platform-dma.c +1 -22
@@ -14,7 +14,7 @@#include <mach/mx28.h> #include <mach/devices-common.h> -static struct platform_device *__init mxs_add_dma (const char *devid, +struct platform_device *__init mxs_add_dma (const char *devid,resource_size_t base) {struct resource res[] = {
@@ -29,24 +29,3 @@ static struct platform_device *__init mxs_add_dma(const char *devid, res,ARRAY_SIZE (res),NULL ,0 , DMA_BIT_MASK(32)); } - -static int __init mxs_add_mxs_dma (void ) -{ -char *mx23_apbh ="imx23-dma-apbh" ; -char *mx23_apbx ="imx23-dma-apbx" ; -char *mx28_apbh ="imx28-dma-apbh" ; -char *mx28_apbx ="imx28-dma-apbx" ; - -if (cpu_is_mx23 ()) { -mxs_add_dma (mx23_apbh,MX23_APBH_DMA_BASE_ADDR ); -mxs_add_dma (mx23_apbx,MX23_APBX_DMA_BASE_ADDR ); - } - -if (cpu_is_mx28 ()) { -mxs_add_dma (mx28_apbh,MX28_APBH_DMA_BASE_ADDR ); -mxs_add_dma (mx28_apbx,MX28_APBX_DMA_BASE_ADDR ); - } - -return 0 ; -} -arch_initcall (mxs_add_mxs_dma);
arch/arm/mach-mxs/include/mach/common.h +4 -0
@@ -19,11 +19,13 @@ extern void mxs_timer_init(struct clk *, int);extern void mxs_restart (char ,const char *);extern int mxs_saif_clkmux_select (unsigned int clkmux); +extern void mx23_soc_init (void );extern int mx23_register_gpios (void );extern int mx23_clocks_init (void );extern void mx23_map_io (void );extern void mx23_init_irq (void ); +extern void mx28_soc_init (void );extern int mx28_register_gpios (void );extern int mx28_clocks_init (void );extern void mx28_map_io (void );
@@ -33,4 +35,6 @@ extern void icoll_init_irq(void);extern int mxs_clkctrl_timeout (unsigned int reg_offset,unsigned int mask); +extern struct platform_device *mxs_add_dma (const char *devid, +resource_size_t base);#endif /* __MACH_MXS_COMMON_H__ */
arch/arm/mach-mxs/mach-apx4devkit.c +2 -0
@@ -207,6 +207,8 @@ static int apx4devkit_phy_fixup(struct phy_device *phy)static void __init apx4devkit_init (void ) { +mx28_soc_init (); +mxs_iomux_setup_multiple_pads (apx4devkit_pads,ARRAY_SIZE (apx4devkit_pads));
arch/arm/mach-mxs/mach-m28evk.c +2 -0
@@ -319,6 +319,8 @@ static struct mxs_mmc_platform_data m28evk_mmc_pdata[] __initdata = {static void __init m28evk_init (void ) { +mx28_soc_init (); +mxs_iomux_setup_multiple_pads (m28evk_pads,ARRAY_SIZE (m28evk_pads));mx28_add_duart ();
arch/arm/mach-mxs/mach-mx23evk.c +2 -0
@@ -141,6 +141,8 @@ static void __init mx23evk_init(void) {int ret; +mx23_soc_init (); +mxs_iomux_setup_multiple_pads (mx23evk_pads,ARRAY_SIZE (mx23evk_pads));mx23_add_duart ();
arch/arm/mach-mxs/mach-mx28evk.c +2 -0
@@ -413,6 +413,8 @@ static void __init mx28evk_init(void) {int ret; +mx28_soc_init (); +mxs_iomux_setup_multiple_pads (mx28evk_pads,ARRAY_SIZE (mx28evk_pads));mx28_add_duart ();
arch/arm/mach-mxs/mach-stmp378x_devb.c +2 -0
@@ -85,6 +85,8 @@ static void __init stmp378x_dvb_init(void) {int ret; +mx23_soc_init (); +mxs_iomux_setup_multiple_pads (stmp378x_dvb_pads,ARRAY_SIZE (stmp378x_dvb_pads));
arch/arm/mach-mxs/mach-tx28.c +2 -0
@@ -146,6 +146,8 @@ static struct mxs_mmc_platform_data tx28_mmc0_pdata __initdata = {static void __init tx28_stk5v3_init (void ) { +mx28_soc_init (); +mxs_iomux_setup_multiple_pads (tx28_stk5v3_pads,ARRAY_SIZE (tx28_stk5v3_pads));
arch/arm/mach-mxs/mm.c +12 -0
@@ -61,3 +61,15 @@ void __init mx28_init_irq(void) {icoll_init_irq (); } + +void __init mx23_soc_init (void ) +{ +mxs_add_dma ("imx23-dma-apbh" ,MX23_APBH_DMA_BASE_ADDR ); +mxs_add_dma ("imx23-dma-apbx" ,MX23_APBX_DMA_BASE_ADDR ); +} + +void __init mx28_soc_init (void ) +{ +mxs_add_dma ("imx28-dma-apbh" ,MX23_APBH_DMA_BASE_ADDR ); +mxs_add_dma ("imx28-dma-apbx" ,MX23_APBX_DMA_BASE_ADDR ); +}
Signature · 1 line
1.7.0.4
PATCH v2 5/5 ARM: mx28evk: add mxs-dma dt support
In reply to Dong AishengFrom: Dong Aisheng <[email protected]>
--- arch/arm/boot/dts/imx28.dtsi | 4 ++-- arch/arm/mach-mxs/clock-mx28.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/boot/dts/imx28.dtsi +2 -2
@@ -52,8 +52,8 @@ }; dma-apbh at 80004000 { + compatible = "fsl,imx28-dma-apbh"; reg = <0x80004000 2000>; - status = "disabled"; }; perfmon at 80006000 {
@@ -115,8 +115,8 @@ }; dma-apbx at 80024000 { + compatible = "fsl,imx28-dma-apbx"; reg = <0x80024000 2000>; - status = "disabled"; }; dcp at 80028000 {
arch/arm/mach-mxs/clock-mx28.c +2 -0
@@ -652,6 +652,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("80074000.serial", NULL, uart_clk) _REGISTER_CLOCK("800f0000.ethernet", NULL, fec_clk) _REGISTER_CLOCK("800f4000.ethernet", NULL, fec_clk) + _REGISTER_CLOCK("80004000.dma-apbh", NULL, hbus_clk) + _REGISTER_CLOCK("80024000.dma-apbx", NULL, xbus_clk) };static int clk_misc_init (void )
Signature · 1 line
1.7.0.4
PATCH v2 1/5 dma: mxs-dma: use global stmp_device functionality
In reply to Dong AishengQuoted 2 lines · Dong Aisheng
#include <
asm/irq.h>
-#include <mach/mxs.h>
I do not think you can remove this inclusion in this patch, since the use of cpu_is_mx23() does not get removed from mxs-dma driver until patch #2.
You do not have to resend the series, if there are no other outstanding comments coming up. I expect the series will go through arm-soc tree to ease the merging. I can fix it when applying the series.
Hi Vinod,
Please let me know if you have problem with the series going through arm-soc than dma tree. Thanks.
Quoted 1 line
-#include <
mach/common.h>
Signature · 2 lines
Regards, Shawn
PATCH v2 1/5 dma: mxs-dma: use global stmp_device functionality
Quoted 8 lines · Shawn Guo
Quoted 2 lines · Dong Aisheng
#include <
asm/irq.h>
-#include <mach/mxs.h>I do not think you can remove this inclusion in this patch, since the use of
cpu_is_mx23()does not get removed from mxs-dma driver until patch #2.
Yes. I missed somehow.
Quoted 4 lines
You do not have to resend the series, if there are no other outstanding comments coming up. I expect the series will go through arm-soc tree to ease the merging. I can fix it when applying the series.
Thanks.
Regards
Dong Aisheng
Quoted 11 lines
Hi Vinod,
Please let me know if you have problem with the series going through arm-soc than dma tree. Thanks.
Quoted 1 line
-#include <
mach/common.h>Signature · 2 lines
Regards, Shawn
PATCH v2 1/5 dma: mxs-dma: use global stmp_device functionality
In reply to Dong AishengQuoted 11 lines · Dong Aisheng
From: Dong Aisheng <[email protected]>
This can get rid of the mach-dependency.
Cc Vinod Koul <[email protected]>Cc Dan Williams <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Huang Shijie <[email protected]>Reviewed-by Marek Vasut <[email protected]>Signed-off-by Dong Aisheng <[email protected]>
Looks good to me, thanks!
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120504/f0910967/attachment.sig>