generic iMX-spi driver
Subsystems (4)
RFC 1/1 generic iMX-spi driver
Hi,
so, _finally_ here is a first RFC for the generic SPI-driver for all imx-platforms. So far, it is only tested on a phyCORE-i.MX27. Still, I can control the audiomixer there. Next week, I will test it on a phyCORE-i.MX31, too. Please note the following:
- one fat patch for now. I hope I can split it up, later, if needed.
- not yet checkpatch clean, will clean up when all the functionality works (mostly 80 char-issues)
- the clock-name for clk_get is hardcoded for now. Will be adapted to the reworked clock-framework when available.
- chip-select is not implemented yet, will do this next week. The driver currently works on CS0 only.
- DMA is just selectable for MX1 and untested.
- If you can comment on the "XXX"-marked issue, please do
- ATTENTION: The original FSL-driver has a bug regarding the polarity CPOL which got flipped. So, if you used the FSL-driver before, then the SPI_MODE of your spi_device has to be corrected. Just toggle SPI_CPOL or make SPI_MODE_0 out of SPI_MODE_2, SPI_MODE_1 out of SPI_MODE_3 or vice versa.
I'd be happy to hear comments, test-reports...
Have a nice weekend,
Wolfram
not yet for upstream...
--- arch/arm/plat-mxc/include/mach/spi_imx.h | 72 ++++ drivers/spi/Kconfig | 12 +- drivers/spi/spi_imx.c | 687 +++++++++++++++++------------- 3 files changed, 465 insertions(+), 306 deletions(-) create mode 100644 arch/arm/plat-mxc/include/mach/spi_imx.h
arch/arm/plat-mxc/include/mach/spi_imx.h new file +72 -0
@@ -0,0 +1,72 @@ +/* +* arch/arm/plat-mxc/include/mach/spi_imx.h +* +* Copyright (C) 2006 SWAPP +* Andrea Paterniani <a.paterniani-03BXCEkGbFHYGGNLXY5/[email protected]> +* Copyright (C) 2009 Pengutronix +* Wolfram Sang <[email protected]> +* +* Initial version inspired by: +* linux-2.6.17-rc3-mm1/arch/arm/mach-pxa/include/mach/pxa2xx_spi.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef SPI_IMX_H_ +#define SPI_IMX_H_ + +/*-------------------------------------------------------------------------*/ +/** +* struct spi_imx_master - device.platform_data for SPI controller devices. +* @num_chipselect: chipselects are used to distinguish individual +* SPI slaves, and are numbered from zero to num_chipselects - 1. +* each slave has a chipselect signal, but it's common that not +* every chipselect is connected to a slave. +* @enable_dma: if true enables DMA driven transfers. +*/ +struct spi_imx_master { +u8 num_chipselect; +u8 enable_dma:1 ; +int (*init)(struct platform_device *pdev); +int (*exit)(struct platform_device *pdev); +}; +/*-------------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------------*/ +/** +* struct spi_imx_chip - spi_board_info.controller_data for SPI +* slave devices, copied to spi_device.controller_data. +* @enable_loopback : used for test purpouse to internally connect RX and TX +* sections. +* @enable_dma : enables dma transfer (provided that controller driver has +* dma enabled too). +* @ins_ss_pulse : enable /SS pulse insertion between SPI burst. +* @bclk_wait : number of bclk waits between each bits_per_word SPI burst. +* @cs_control : function pointer to board-specific function to assert/deassert +* I/O port to control HW generation of devices chip-select. +*/ +struct spi_imx_chip { +u8 enable_dma:1 ; +u8 ins_ss_pulse:1 ; +u16 bclk_wait:15 ; +void (*cs_control)(u32 control); +}; + +/* Chip-select state */ +#define SPI_CS_ASSERT (1 << 0) +#define SPI_CS_DEASSERT (1 << 1) +/*-------------------------------------------------------------------------*/ + +#endif /* SPI_IMX_H_*/
drivers/spi/Kconfig +9 -3
@@ -117,12 +117,18 @@ config SPI_GPIO speed with a custom version of this driver; see the source code. config SPI_IMX - tristate "Freescale iMX SPI controller" - depends on ARCH_IMX && EXPERIMENTAL + tristate "Freescale iMX SPI controllers" + depends on (ARCH_IMX || ARCH_MXC) && EXPERIMENTAL help - This enables using the Freescale iMX SPI controller in master + This enables using the Freescale iMX SPI controllers in master mode. +config SPI_IMX_DMA + bool "use DMA for iMX SPI controllers" + depends on SPI_IMX && ARCH_IMX + help + This enables DMA usage for the Freescale iMX SPI controllers. + config SPI_LM70_LLP tristate "Parallel port adapter for LM70 eval board (DEVELOPMENT)" depends on PARPORT && EXPERIMENTAL
drivers/spi/spi_imx.c +384 -303
1,231 lines not on this page · raw message
Signature · 7 lines
1.5.6.5 -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5064 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): [email protected]
Me again,
here is an example patch what I needed to do in order to switch from the old FSL-driver to this one. Hope it helps.
--- arch/arm/mach-mx2/devices.c | 6 +++--- arch/arm/mach-mx2/pcm038.c | 7 ++++--- drivers/mxc/pmic/Kconfig | 2 +- drivers/mxc/pmic/core/mc13783.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-)
arm/mach-mx2/devices.c renamed from arm/mach-mx2/devices.c.orig +3 -3
@@ -143,14 +143,14 @@ static struct resource mxc_spi_resources#endif struct platform_device mxc_spi_device0 = { - .name ="mxc_spi" , + .name ="spi_imx" , .id =0 , .num_resources =ARRAY_SIZE (mxc_spi_resources0), .resource = mxc_spi_resources0, };struct platform_device mxc_spi_device1 = { - .name ="mxc_spi" , + .name ="spi_imx" , .id =1 , .num_resources =ARRAY_SIZE (mxc_spi_resources1), .resource = mxc_spi_resources1,
@@ -158,7 +158,7 @@ struct platform_device mxc_spi_device1 =#ifdef CONFIG_MACH_MX27 struct platform_device mxc_spi_device2 = { - .name ="mxc_spi" , + .name ="spi_imx" , .id =2 , .num_resources =ARRAY_SIZE (mxc_spi_resources2), .resource = mxc_spi_resources2,
arm/mach-mx2/pcm038.c renamed from arm/mach-mx2/pcm038.c.orig +4 -3
@@ -37,7 +37,8 @@#include <mach/iomux-mx1-mx2.h> #include <mach/gpio.h> #include <mach/i2c.h> -#include <mach/imx_spi.h> +//#include <mach/imx_spi.h> +#include <mach/spi_imx.h> #include <mach/imx-uart.h> #include <mach/imx_ssi.h> #include <mach/pmic/platform.h>
@@ -178,8 +179,8 @@ static int gpio_spi_inactive_0(struct plreturn 0 ; } -static struct mxc_spi_master pcm038_spi_0_data = { - .maxchipselect =4 ,/* FIXME */ +static struct spi_imx_master pcm038_spi_0_data = { + .num_chipselect =4 ,/* FIXME */ .init = gpio_spi_active_0, .exit = gpio_spi_inactive_0, };
mxc/pmic/Kconfig renamed from mxc/pmic/Kconfig.orig +1 -1
@@ -6,7 +6,7 @@ menu "MXC PMIC support" config MXC_SPI_PMIC_CORE tristate "PMIC Protocol support (SPI interface)" - depends on ARCH_MX2 && SPI_MXC + depends on ARCH_MX2 && (SPI_MXC || SPI_IMX) default n help This is the PMIC core/protocol driver for the Freescale MXC application.
mxc/pmic/core/mc13783.c renamed from mxc/pmic/core/mc13783.c.orig +1 -1
@@ -117,7 +117,7 @@ int pmic_spi_setup(struct spi_device *sp/* Setup the SPI slave i.e.PMIC */ pmic_drv_data.spi = spi; - spi->mode =SPI_MODE_2 |SPI_CS_HIGH ; + spi->mode =SPI_MODE_0 |SPI_CS_HIGH ; spi->bits_per_word =32 ;return spi_setup (spi);
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
arch/arm/plat-mxc/include/mach/spi_imx.h line 43
Quoted 1 line
arch/arm/plat-mxc/include/mach/spi_imx.h new file +1
-0+int (*exit)(struct platform_device *pdev);
void (*exit)(struct platform_device *pdev);
Quoted 23 lines
drivers/spi/spi_imx.c +23
-0+struct spi_core_version { +u32 rxdata; +u32 txdata; +u32 ctrl; +u32 int_en; +u32 status; +u32 test; +u32 period; +u32 dma; +u32 reset; + +u32 int_te; +u32 int_th; +u32 int_ro; +u32 int_te_en; +u32 int_th_en; +u32 int_ro_en; +u32 xch; + +u8 bitcount_shift; +u8 sspol_shift; +u8 ssctl_shift; +u8 pha_shift;
drivers/spi/spi_imx.c line 159
Quoted 10 lines
drivers/spi/spi_imx.c +9
-0+u8 pol_shift; +u8 datarate_shift; +u8 reset_val; + +u32 max_divider; +u32 max_bitcount; +u32 default_ctrl; +u32 (*calc_datarate)(struct driver_data *drv_data,u32 speed_hz,u32 *val); +};
A number of u8's in the middle of a structure where later 32 bit long entries are comming?
Move that to the end or change it to 32 (I yet have to verify if the compiler creates stupid or good code when accessing u8 out of a struct, but I assume that on ARM the code is more-or-less stupid).
drivers/spi/spi_imx.c static int __init spi_imx_probe(struct platform_device *pdev) · line 1551
Quoted 3 lines
drivers/spi/spi_imx.c +3
-0+/* Setup any GPIO active */ +if (platform_info->init) + platform_info->init (pdev);
This function can fail, so you need to handle the error case.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
A message that is not in the archive (sent off-list or not yet received): 200902201641.21168.hs4233-x6+DxXLjN1AJvtFkdXX2Hg4jNU5vUVPG@public.gmane.org
Quoted 3 lines · Holger Schurig
arch/arm/plat-mxc/include/mach/spi_imx.h line 43
Quoted 1 line
arch/arm/plat-mxc/include/mach/spi_imx.h new file +1
-0+int (*exit)(struct platform_device *pdev);void (*exit)(struct
platform_device*pdev);
Fixed (Hmm, quite some more candidates for this one in mach/)
Quoted 37 lines
Quoted 23 lines
drivers/spi/spi_imx.c +23
-0+struct spi_core_version { +u32 rxdata; +u32 txdata; +u32 ctrl; +u32 int_en; +u32 status; +u32 test; +u32 period; +u32 dma; +u32 reset; + +u32 int_te; +u32 int_th; +u32 int_ro; +u32 int_te_en; +u32 int_th_en; +u32 int_ro_en; +u32 xch; + +u8 bitcount_shift; +u8 sspol_shift; +u8 ssctl_shift; +u8 pha_shift;drivers/spi/spi_imx.c line 159
Quoted 10 lines
drivers/spi/spi_imx.c +9
-0+u8 pol_shift; +u8 datarate_shift; +u8 reset_val; + +u32 max_divider; +u32 max_bitcount; +u32 default_ctrl; +u32 (*calc_datarate)(struct driver_data *drv_data,u32 speed_hz,u32 *val); +};A number of u8's in the middle of a structure where later 32 bit long entries are comming?
Quoted 3 lines
Move that to the end or change it to 32 (I yet have to verify if the compiler creates stupid or good code when accessing u8 out of a struct, but I assume that on ARM the code is more-or-less stupid).
Well, could be that I thought too much about size vs. performance issues here. My idea was to put the variables needed in hot-paths to the front of the struct.
All variables starting from the u8-block are just used in initialization routines and so I tended to size-optimize here as we need at least six of such structs.
I'm open for suggestions, though.
Quoted 5 lines
drivers/spi/spi_imx.c static int __init spi_imx_probe(struct platform_device *pdev) · line 1551
Quoted 3 lines
drivers/spi/spi_imx.c +3
-0+/* Setup any GPIO active */ +if (platform_info->init) + platform_info->init (pdev);This function can fail, so you need to handle the error case.
Fixed.
Thanks for your comments.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 38 lines · Wolfram Sang
Quoted 37 lines · Holger Schurig
Quoted 23 lines
drivers/spi/spi_imx.c +23
-0+struct spi_core_version { +u32 rxdata; +u32 txdata; +u32 ctrl; +u32 int_en; +u32 status; +u32 test; +u32 period; +u32 dma; +u32 reset; + +u32 int_te; +u32 int_th; +u32 int_ro; +u32 int_te_en; +u32 int_th_en; +u32 int_ro_en; +u32 xch; + +u8 bitcount_shift; +u8 sspol_shift; +u8 ssctl_shift; +u8 pha_shift;drivers/spi/spi_imx.c line 159
Quoted 10 lines
drivers/spi/spi_imx.c +9
-0+u8 pol_shift; +u8 datarate_shift; +u8 reset_val; + +u32 max_divider; +u32 max_bitcount; +u32 default_ctrl; +u32 (*calc_datarate)(struct driver_data *drv_data,u32 speed_hz,u32 *val); +};A number of u8's in the middle of a structure where later 32 bit long entries are comming?
Quoted 7 lines
Quoted 3 lines
Move that to the end or change it to 32 (I yet have to verify if the compiler creates stupid or good code when accessing u8 out of a struct, but I assume that on ARM the code is more-or-less stupid).
Well, could be that I thought too much about size vs. performance issues here. My idea was to put the variables needed in hot-paths to the front of the struct.
That is a good reason for ordering structs like this. ARM does generate good code for accessing bytes in structures - it does have a byte load instruction.
What it does do though is want to naturally align structure members, so it's a good idea to group u8's together up to the next members natural boundary. So:
struct {
u32 hot_32_1;
u8 hot_8_1;
u8 hot_8_2;
u32 hot_32_2;
u32 cold_32_1;
u8 cold_8_1;
u8 cold_8_2;
u32 cold_32_2;
};would be a silly layout - you'd end up adding an additional four bytes for no gain. Instead:
struct {
u32 hot_32_1;
u8 hot_8_1;
u8 hot_8_2;
u8 cold_8_1;
u8 cold_8_2;
u32 hot_32_2;
u32 cold_32_1;
u32 cold_32_2;
};would be optimal use of memory without breaking the proximty of the hot members (since you've put the two cold bytes into the wastage bytes.)
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
A message that is not in the archive (sent off-list or not yet received): 20090226232639.GF5811-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org
Quoted 3 lines
What it does do though is want to naturally align structure members, so it's a good idea to group u8's together up to the next members natural boundary. So:
All the hot-path variables are u32 as I don't want to do shifting there. The u8-members are all cold-path, so I can use them as shift counters. They happen to be 8 in V2, so that seems to fit, too (for now that is). I know about aligning and will keep an eye on this.
One more thing I had in mind: As every access to a register now looks like
'regs + drv_data->version->$some_offset'
I also wondered if it would pay off to add the register base to the offset already in the probe routine, so we then can reduce the access to simply
'drv_data->version->$some_reg'
But this is for later, after the driver is stable, I think.
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Wolfram Sang
Quoted 3 lines
What it does do though is want to naturally align structure members, so it's a good idea to group u8's together up to the next members natural boundary. So:
All the hot-path variables are u32 as I don't want to do shifting there. The u8-members are all cold-path, so I can use them as shift counters.
What shifting are you referring to? ARM GCC doesn't load a word and then shift to get at the byte it's interested in. It uses the ARM byte load instruction or byte store instruction which are just as fast as word loads or stores.
Quoted 5 lines
One more thing I had in mind: As every access to a register now looks like
'regs + drv_data->version->$some_offset'
Quoted 7 lines
I also wondered if it would pay off to add the register base to the offset already in the probe routine, so we then can reduce the access to simply
'drv_data->version->$some_reg'
But this is for later, after the driver is stable, I think.
The load instruction combines addition or subtraction:
ldr rd, [rn, rm]
optionally with a constant shift for 'rm', so the first version is entirely possible for the compiler to use one instruction to access [regs + offset] in one instruction.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
A message that is not in the archive (sent off-list or not yet received): 20090302205826.GG25699-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org
Hi,
what's the state of this patch? Is a new revision planned soon to go in for 2.6.31?
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
Quoted 2 lines · Guennadi Liakhovetski
what's the state of this patch? Is a new revision planned soon to go in for 2.6.31?
No idea, as far as I can see after my last comments, it's dead.
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.64.0904302343470.9542-0199iw4Nj15frtckUFj5Ag@public.gmane.org
Hi Guennadi,
Quoted 4 lines · Guennadi Liakhovetski
Hi,
what's the state of this patch? Is a new revision planned soon to go in for 2.6.31?
I'm currently working on pimping the Freescale driver and so far it looks much better and more flexible than the in Kernel driver. I'll post a patch later this evening.
Sascha
Signature · 11 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
Quoted 10 lines · Wolfram Sang
drivers/spi/spi_imx.c +2
-0@@ -1646,6 +1706,8 @@ static int __exit spi_imx_remove(struct platform_device *pdev)struct driver_data *drv_data =platform_get_drvdata (pdev);int irq;int status =0 ; +struct spi_imx_master *platform_info = + (struct spi_imx_master *)pdev->dev.platform_data;if (!drv_data)return 0 ;
drivers/spi/spi_imx.c static int __exit spi_imx_remove(struct platform_device *pdev) · line 1725
Quoted 5 lines
drivers/spi/spi_imx.c +2
-0@@ -1659,10 +1721,13 @@ static int __exit spi_imx_remove(struct platform_device *pdev)return status; } +if (platform_info->exit) + platform_info->exit (pdev);
platform_info can be NULL here if when declaring platform_device platform data was not set. In this case you will get crash here.
Should be if (platform_info && platform_info->exit)
Quoted 33 lines
drivers/spi/spi_imx.c +6
-4+/* Reset SPI */ -writel (SPI_RESET_START , drv_data->regs +SPI_RESET ); -writel (0 , drv_data->regs +SPI_RESET ); +writel (drv_data->version->reset_val, drv_data->regs + drv_data->version->reset); +#ifdef CONFIG_SPI_IMX_DMA /* Release DMA */ if (drv_data->master_info->enable_dma) {RSSR (drv_data->rx_channel) =0 ;@@ -1670,6 +1735,7 @@ static int __exit spi_imx_remove(struct platform_device *pdev)imx_dma_free (drv_data->tx_channel); imx_dma_free(drv_data->rx_channel); } +#endif /* DMA */ /* Release IRQ */ irq =platform_get_irq (pdev,0 );@@ -1701,8 +1767,7 @@ static void spi_imx_shutdown(struct platform_device *pdev)struct driver_data *drv_data =platform_get_drvdata (pdev);/* Reset SPI */ -writel (SPI_RESET_START , drv_data->regs +SPI_RESET ); -writel (0 , drv_data->regs +SPI_RESET ); +writel (drv_data->version->reset_val, drv_data->regs + drv_data->version->reset);dev_dbg (&pdev->dev,"shutdown succeded\n" ); }@@ -1714,12 +1779,20 @@ static int spi_imx_suspend(struct platform_device *pdev, pm_message_t state)struct driver_data *drv_data =platform_get_drvdata (pdev);int status =0 ; + struct spi_imx_master *platform_info =
drivers/spi/spi_imx.c static int spi_imx_suspend(struct platform_device *pdev, pm_message_t state) · line 1792
Quoted 10 lines
drivers/spi/spi_imx.c +4
-0+ (struct spi_imx_master *)pdev->dev.platform_data; + status =stop_queue (drv_data);if (status !=0 ) {dev_warn (&pdev->dev,"suspend cannot stop queue\n" );return status; } +if (platform_info->exit) + platform_info->exit (pdev);
ditto
Quoted 7 lines
drivers/spi/spi_imx.c +3
-0+ +clk_disable (drv_data->clk); +dev_dbg (&pdev->dev,"suspended\n" );return 0 ;
drivers/spi/spi_imx.c static int spi_imx_resume(struct platform_device *pdev) · line 1812
Quoted 10 lines
drivers/spi/spi_imx.c +7
-0@@ -1730,6 +1803,14 @@ static int spi_imx_resume(struct platform_device *pdev)struct driver_data *drv_data =platform_get_drvdata (pdev);int status =0 ; +struct spi_imx_master *platform_info = + (struct spi_imx_master *)pdev->dev.platform_data; + +clk_enable (drv_data->clk); + +if (platform_info->init) + platform_info->init (pdev);
ditto
drivers/spi/spi_imx.c static int spi_imx_resume(struct platform_device *pdev) · line 1816
Quoted 4 lines
drivers/spi/spi_imx.c +1
-0+/* Start the queue running */ status =start_queue (drv_data);if (status !=0 )
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines
drivers/spi/spi_imx.c static int __exit spi_imx_remove(struct platform_device *pdev) · line 1725
Quoted 7 lines
drivers/spi/spi_imx.c +2
-0@@ -1659,10 +1721,13 @@ static int __exit spi_imx_remove(struct platform_device *pdev)return status; } +if (platform_info->exit) + platform_info->exit (pdev);
platform_infocan be NULL here if when declaringplatform_deviceplatform data was not set. In this case you will get crash here.
Should be if (platform_info&&platform_info->exit)
Well, that is the first thing the probe function checks :) It will fail if there is no platform_data.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · Wolfram Sang
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi_imx.c +0
-0@@ -1659,10 +1721,13 @@ static int __exit spi_imx_remove(struct platform_device *pdev)return status; }
Quoted 8 lines
Quoted 5 lines
Review static int __exit spi_imx_remove(struct platform_device *pdev) · line 1725
Quoted 2 lines
(quoted diff) +2
-0+ if (platform_info->exit) + platform_info->exit(pdev);
platform_infocan be NULL here if when declaringplatform_deviceplatform data was not set. In this case you will get crash here.
Should be if (platform_info&&platform_info->exit)Well, that is the first thing the probe function checks :) It will fail if there is no
platform_data.
OK then. I missed that check :|
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H