diff options
-rw-r--r-- | arch/arm/mach-mxs/devices/platform-dma.c | 14 | ||||
-rw-r--r-- | drivers/clk/mxs/clk-imx23.c | 4 | ||||
-rw-r--r-- | drivers/clk/mxs/clk-imx28.c | 4 | ||||
-rw-r--r-- | drivers/dma/mxs-dma.c | 115 | ||||
-rw-r--r-- | include/linux/fsl/mxs-dma.h | 12 |
5 files changed, 93 insertions, 56 deletions
diff --git a/arch/arm/mach-mxs/devices/platform-dma.c b/arch/arm/mach-mxs/devices/platform-dma.c index 6a0202b1016c..aff481360212 100644 --- a/arch/arm/mach-mxs/devices/platform-dma.c +++ b/arch/arm/mach-mxs/devices/platform-dma.c | |||
@@ -32,17 +32,19 @@ static struct platform_device *__init mxs_add_dma(const char *devid, | |||
32 | 32 | ||
33 | static int __init mxs_add_mxs_dma(void) | 33 | static int __init mxs_add_mxs_dma(void) |
34 | { | 34 | { |
35 | char *apbh = "mxs-dma-apbh"; | 35 | char *mx23_apbh = "imx23-dma-apbh"; |
36 | char *apbx = "mxs-dma-apbx"; | 36 | char *mx23_apbx = "imx23-dma-apbx"; |
37 | char *mx28_apbh = "imx28-dma-apbh"; | ||
38 | char *mx28_apbx = "imx28-dma-apbx"; | ||
37 | 39 | ||
38 | if (cpu_is_mx23()) { | 40 | if (cpu_is_mx23()) { |
39 | mxs_add_dma(apbh, MX23_APBH_DMA_BASE_ADDR); | 41 | mxs_add_dma(mx23_apbh, MX23_APBH_DMA_BASE_ADDR); |
40 | mxs_add_dma(apbx, MX23_APBX_DMA_BASE_ADDR); | 42 | mxs_add_dma(mx23_apbx, MX23_APBX_DMA_BASE_ADDR); |
41 | } | 43 | } |
42 | 44 | ||
43 | if (cpu_is_mx28()) { | 45 | if (cpu_is_mx28()) { |
44 | mxs_add_dma(apbh, MX28_APBH_DMA_BASE_ADDR); | 46 | mxs_add_dma(mx28_apbh, MX28_APBH_DMA_BASE_ADDR); |
45 | mxs_add_dma(apbx, MX28_APBX_DMA_BASE_ADDR); | 47 | mxs_add_dma(mx28_apbx, MX28_APBX_DMA_BASE_ADDR); |
46 | } | 48 | } |
47 | 49 | ||
48 | return 0; | 50 | return 0; |
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c index 07fe1f1b4b70..96562f5f92f7 100644 --- a/drivers/clk/mxs/clk-imx23.c +++ b/drivers/clk/mxs/clk-imx23.c | |||
@@ -81,14 +81,14 @@ static struct clk_lookup uart_lookups[] __initdata = { | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | static struct clk_lookup hbus_lookups[] __initdata = { | 83 | static struct clk_lookup hbus_lookups[] __initdata = { |
84 | { .dev_id = "mxs-dma-apbh", }, | 84 | { .dev_id = "imx23-dma-apbh", }, |
85 | { .dev_id = "80004000.dma-apbh", }, | 85 | { .dev_id = "80004000.dma-apbh", }, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static struct clk_lookup xbus_lookups[] __initdata = { | 88 | static struct clk_lookup xbus_lookups[] __initdata = { |
89 | { .dev_id = "duart", .con_id = "apb_pclk"}, | 89 | { .dev_id = "duart", .con_id = "apb_pclk"}, |
90 | { .dev_id = "80070000.serial", .con_id = "apb_pclk"}, | 90 | { .dev_id = "80070000.serial", .con_id = "apb_pclk"}, |
91 | { .dev_id = "mxs-dma-apbx", }, | 91 | { .dev_id = "imx23-dma-apbx", }, |
92 | { .dev_id = "80024000.dma-apbx", }, | 92 | { .dev_id = "80024000.dma-apbx", }, |
93 | }; | 93 | }; |
94 | 94 | ||
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c index 5be4636c45a6..a7ff4f106ce2 100644 --- a/drivers/clk/mxs/clk-imx28.c +++ b/drivers/clk/mxs/clk-imx28.c | |||
@@ -136,14 +136,14 @@ static struct clk_lookup uart_lookups[] __initdata = { | |||
136 | }; | 136 | }; |
137 | 137 | ||
138 | static struct clk_lookup hbus_lookups[] __initdata = { | 138 | static struct clk_lookup hbus_lookups[] __initdata = { |
139 | { .dev_id = "mxs-dma-apbh", }, | 139 | { .dev_id = "imx28-dma-apbh", }, |
140 | { .dev_id = "80004000.dma-apbh", }, | 140 | { .dev_id = "80004000.dma-apbh", }, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | static struct clk_lookup xbus_lookups[] __initdata = { | 143 | static struct clk_lookup xbus_lookups[] __initdata = { |
144 | { .dev_id = "duart", .con_id = "apb_pclk"}, | 144 | { .dev_id = "duart", .con_id = "apb_pclk"}, |
145 | { .dev_id = "80074000.serial", .con_id = "apb_pclk"}, | 145 | { .dev_id = "80074000.serial", .con_id = "apb_pclk"}, |
146 | { .dev_id = "mxs-dma-apbx", }, | 146 | { .dev_id = "imx28-dma-apbx", }, |
147 | { .dev_id = "80024000.dma-apbx", }, | 147 | { .dev_id = "80024000.dma-apbx", }, |
148 | }; | 148 | }; |
149 | 149 | ||
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index c93f9fa08caf..b1cab087cd04 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c | |||
@@ -36,12 +36,8 @@ | |||
36 | * dma can program the controller registers of peripheral devices. | 36 | * dma can program the controller registers of peripheral devices. |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #define MXS_DMA_APBH 0 | 39 | #define dma_is_apbh(mxs_dma) ((mxs_dma)->type == MXS_DMA_APBH) |
40 | #define MXS_DMA_APBX 1 | 40 | #define apbh_is_old(mxs_dma) ((mxs_dma)->dev_id == IMX23_DMA) |
41 | #define dma_is_apbh(mxs_dma) ((mxs_dma)->dev_id == MXS_DMA_APBH) | ||
42 | |||
43 | #define APBH_VERSION_LATEST 3 | ||
44 | #define apbh_is_old(mxs_dma) ((mxs_dma)->version < APBH_VERSION_LATEST) | ||
45 | 41 | ||
46 | #define HW_APBHX_CTRL0 0x000 | 42 | #define HW_APBHX_CTRL0 0x000 |
47 | #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29) | 43 | #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29) |
@@ -51,9 +47,6 @@ | |||
51 | #define HW_APBHX_CTRL2 0x020 | 47 | #define HW_APBHX_CTRL2 0x020 |
52 | #define HW_APBHX_CHANNEL_CTRL 0x030 | 48 | #define HW_APBHX_CHANNEL_CTRL 0x030 |
53 | #define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16 | 49 | #define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16 |
54 | #define HW_APBH_VERSION (cpu_is_mx23() ? 0x3f0 : 0x800) | ||
55 | #define HW_APBX_VERSION 0x800 | ||
56 | #define BP_APBHX_VERSION_MAJOR 24 | ||
57 | /* | 50 | /* |
58 | * The offset of NXTCMDAR register is different per both dma type and version, | 51 | * The offset of NXTCMDAR register is different per both dma type and version, |
59 | * while stride for each channel is all the same 0x70. | 52 | * while stride for each channel is all the same 0x70. |
@@ -125,9 +118,19 @@ struct mxs_dma_chan { | |||
125 | #define MXS_DMA_CHANNELS 16 | 118 | #define MXS_DMA_CHANNELS 16 |
126 | #define MXS_DMA_CHANNELS_MASK 0xffff | 119 | #define MXS_DMA_CHANNELS_MASK 0xffff |
127 | 120 | ||
121 | enum mxs_dma_devtype { | ||
122 | MXS_DMA_APBH, | ||
123 | MXS_DMA_APBX, | ||
124 | }; | ||
125 | |||
126 | enum mxs_dma_id { | ||
127 | IMX23_DMA, | ||
128 | IMX28_DMA, | ||
129 | }; | ||
130 | |||
128 | struct mxs_dma_engine { | 131 | struct mxs_dma_engine { |
129 | int dev_id; | 132 | enum mxs_dma_id dev_id; |
130 | unsigned int version; | 133 | enum mxs_dma_devtype type; |
131 | void __iomem *base; | 134 | void __iomem *base; |
132 | struct clk *clk; | 135 | struct clk *clk; |
133 | struct dma_device dma_device; | 136 | struct dma_device dma_device; |
@@ -135,6 +138,66 @@ struct mxs_dma_engine { | |||
135 | struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS]; | 138 | struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS]; |
136 | }; | 139 | }; |
137 | 140 | ||
141 | struct mxs_dma_type { | ||
142 | enum mxs_dma_id id; | ||
143 | enum mxs_dma_devtype type; | ||
144 | }; | ||
145 | |||
146 | static struct mxs_dma_type mxs_dma_types[] = { | ||
147 | { | ||
148 | .id = IMX23_DMA, | ||
149 | .type = MXS_DMA_APBH, | ||
150 | }, { | ||
151 | .id = IMX23_DMA, | ||
152 | .type = MXS_DMA_APBX, | ||
153 | }, { | ||
154 | .id = IMX28_DMA, | ||
155 | .type = MXS_DMA_APBH, | ||
156 | }, { | ||
157 | .id = IMX28_DMA, | ||
158 | .type = MXS_DMA_APBX, | ||
159 | } | ||
160 | }; | ||
161 | |||
162 | static struct platform_device_id mxs_dma_ids[] = { | ||
163 | { | ||
164 | .name = "imx23-dma-apbh", | ||
165 | .driver_data = (kernel_ulong_t) &mxs_dma_types[0], | ||
166 | }, { | ||
167 | .name = "imx23-dma-apbx", | ||
168 | .driver_data = (kernel_ulong_t) &mxs_dma_types[1], | ||
169 | }, { | ||
170 | .name = "imx28-dma-apbh", | ||
171 | .driver_data = (kernel_ulong_t) &mxs_dma_types[2], | ||
172 | }, { | ||
173 | .name = "imx28-dma-apbx", | ||
174 | .driver_data = (kernel_ulong_t) &mxs_dma_types[3], | ||
175 | }, { | ||
176 | /* end of list */ | ||
177 | } | ||
178 | }; | ||
179 | |||
180 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) | ||
181 | { | ||
182 | return container_of(chan, struct mxs_dma_chan, chan); | ||
183 | } | ||
184 | |||
185 | int mxs_dma_is_apbh(struct dma_chan *chan) | ||
186 | { | ||
187 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); | ||
188 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; | ||
189 | |||
190 | return dma_is_apbh(mxs_dma); | ||
191 | } | ||
192 | |||
193 | int mxs_dma_is_apbx(struct dma_chan *chan) | ||
194 | { | ||
195 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); | ||
196 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; | ||
197 | |||
198 | return !dma_is_apbh(mxs_dma); | ||
199 | } | ||
200 | |||
138 | static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan) | 201 | static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan) |
139 | { | 202 | { |
140 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; | 203 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
@@ -198,11 +261,6 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan) | |||
198 | mxs_chan->status = DMA_IN_PROGRESS; | 261 | mxs_chan->status = DMA_IN_PROGRESS; |
199 | } | 262 | } |
200 | 263 | ||
201 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) | ||
202 | { | ||
203 | return container_of(chan, struct mxs_dma_chan, chan); | ||
204 | } | ||
205 | |||
206 | static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx) | 264 | static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx) |
207 | { | 265 | { |
208 | return dma_cookie_assign(tx); | 266 | return dma_cookie_assign(tx); |
@@ -575,12 +633,6 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) | |||
575 | if (ret) | 633 | if (ret) |
576 | goto err_out; | 634 | goto err_out; |
577 | 635 | ||
578 | /* only major version matters */ | ||
579 | mxs_dma->version = readl(mxs_dma->base + | ||
580 | ((mxs_dma->dev_id == MXS_DMA_APBX) ? | ||
581 | HW_APBX_VERSION : HW_APBH_VERSION)) >> | ||
582 | BP_APBHX_VERSION_MAJOR; | ||
583 | |||
584 | /* enable apbh burst */ | 636 | /* enable apbh burst */ |
585 | if (dma_is_apbh(mxs_dma)) { | 637 | if (dma_is_apbh(mxs_dma)) { |
586 | writel(BM_APBH_CTRL0_APB_BURST_EN, | 638 | writel(BM_APBH_CTRL0_APB_BURST_EN, |
@@ -602,6 +654,8 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
602 | { | 654 | { |
603 | const struct platform_device_id *id_entry = | 655 | const struct platform_device_id *id_entry = |
604 | platform_get_device_id(pdev); | 656 | platform_get_device_id(pdev); |
657 | const struct mxs_dma_type *dma_type = | ||
658 | (struct mxs_dma_type *)id_entry->driver_data; | ||
605 | struct mxs_dma_engine *mxs_dma; | 659 | struct mxs_dma_engine *mxs_dma; |
606 | struct resource *iores; | 660 | struct resource *iores; |
607 | int ret, i; | 661 | int ret, i; |
@@ -610,7 +664,8 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
610 | if (!mxs_dma) | 664 | if (!mxs_dma) |
611 | return -ENOMEM; | 665 | return -ENOMEM; |
612 | 666 | ||
613 | mxs_dma->dev_id = id_entry->driver_data; | 667 | mxs_dma->dev_id = dma_type->id; |
668 | mxs_dma->type = dma_type->type; | ||
614 | 669 | ||
615 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 670 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
616 | 671 | ||
@@ -693,23 +748,11 @@ err_request_region: | |||
693 | return ret; | 748 | return ret; |
694 | } | 749 | } |
695 | 750 | ||
696 | static struct platform_device_id mxs_dma_type[] = { | ||
697 | { | ||
698 | .name = "mxs-dma-apbh", | ||
699 | .driver_data = MXS_DMA_APBH, | ||
700 | }, { | ||
701 | .name = "mxs-dma-apbx", | ||
702 | .driver_data = MXS_DMA_APBX, | ||
703 | }, { | ||
704 | /* end of list */ | ||
705 | } | ||
706 | }; | ||
707 | |||
708 | static struct platform_driver mxs_dma_driver = { | 751 | static struct platform_driver mxs_dma_driver = { |
709 | .driver = { | 752 | .driver = { |
710 | .name = "mxs-dma", | 753 | .name = "mxs-dma", |
711 | }, | 754 | }, |
712 | .id_table = mxs_dma_type, | 755 | .id_table = mxs_dma_ids, |
713 | }; | 756 | }; |
714 | 757 | ||
715 | static int __init mxs_dma_module_init(void) | 758 | static int __init mxs_dma_module_init(void) |
diff --git a/include/linux/fsl/mxs-dma.h b/include/linux/fsl/mxs-dma.h index 203d7c4a3e11..55d870238399 100644 --- a/include/linux/fsl/mxs-dma.h +++ b/include/linux/fsl/mxs-dma.h | |||
@@ -15,14 +15,6 @@ struct mxs_dma_data { | |||
15 | int chan_irq; | 15 | int chan_irq; |
16 | }; | 16 | }; |
17 | 17 | ||
18 | static inline int mxs_dma_is_apbh(struct dma_chan *chan) | 18 | extern int mxs_dma_is_apbh(struct dma_chan *chan); |
19 | { | 19 | extern int mxs_dma_is_apbx(struct dma_chan *chan); |
20 | return !strcmp(dev_name(chan->device->dev), "mxs-dma-apbh"); | ||
21 | } | ||
22 | |||
23 | static inline int mxs_dma_is_apbx(struct dma_chan *chan) | ||
24 | { | ||
25 | return !strcmp(dev_name(chan->device->dev), "mxs-dma-apbx"); | ||
26 | } | ||
27 | |||
28 | #endif /* __MACH_MXS_DMA_H__ */ | 20 | #endif /* __MACH_MXS_DMA_H__ */ |