amba_pl022 spi->mode fix/cleanup patches
Subsystems (6)
This patch series updates drivers and platforms that depend on the amba_pl022 driver and use the pl022_config_chip structure for setting up the SPI mode and data transfer width.
The SPI configuration (CPOL/CPHA mode, bit send order, data bits per word, and loopback mode) were previously setup as part of board specific data in the pl022_config_chip structure. This has been changed to now use the .mode field in spi_board_info structure (or drivers that setup the mode). The SPI transfer's data width is now configured from spi->bits_per_word.
The SPI driver changes have been previously submitted to the SPI ML. This patch series need to be layered on that patch series.
These changes add or fix the .mode field in the plats/boards that use the driver (u300, ux500, lpc32xx). The patches also move the data width from the board specific area to the driver for mfd/ab8500. As the fields in the pl022_config_chip structure are no longer needed, they are removed in the last patch.
These changes have been tested on the phy3250 platform (lpc32xx). I was able to test the ab8500 driver to some degree, but I only have a standard pl022. I am unable to test u300 and ux500 changes, but the u300 changes compiled fine.
[PATCH 1/5] mfd/ab8500: Setup SPI transfer for 24 bits [PATCH 2/5] ARM: LPC32XX: Add missing SPI mode and remove unused fields [PATCH 3/5] ARM: U300: spi->mode and spi_bits_per_words updates [PATCH 4/5] ARM: Ux500: Change SPI mode and remove unused fields [PATCH 5/5] spi: amba_pl022: Remove unused fields from pl022_config_chip
PATCH 1/5 mfd/ab8500: Setup SPI transfer for 24 bits
From: Kevin Wells <[email protected]>
The data bit transfer size should be part of the driver using the SPI interface. This was previously setup in the AMBA PL022 driver from board specific configuration data.
--- drivers/mfd/ab8500-spi.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/mfd/ab8500-spi.c +5 -0
@@ -83,6 +83,11 @@ static int __devinit ab8500_spi_probe(struct spi_device *spi)struct ab8500 *ab8500;int ret; + spi->bits_per_word =24 ; + ret =spi_setup (spi); +if (ret <0 ) +return ret; + ab8500 =kzalloc (sizeof *ab8500,GFP_KERNEL );if (!ab8500)return -ENOMEM ;
Signature · 1 line
1.7.2.2
PATCH 2/5 ARM: LPC32XX: Add missing SPI mode and remove unused fields
In reply to [email protected]From: Kevin Wells <[email protected]>
Some of the fields in the pl022_chip_info structure used with the amba pl022 driver are no longer used. This patch removes those unused fields and adds the missing .mode flags to the spi_board_info structure.
--- arch/arm/mach-lpc32xx/phy3250.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
arch/arm/mach-lpc32xx/phy3250.c +1 -6
@@ -172,18 +172,12 @@ static void phy3250_spi_cs_set(u32 control) }static struct pl022_config_chip spi0_chip_info = { - .lbm =LOOPBACK_DISABLED , .com_mode =INTERRUPT_TRANSFER , .iface =SSP_INTERFACE_MOTOROLA_SPI , .hierarchy =SSP_MASTER , .slave_tx_disable =0 , - .endian_tx =SSP_TX_LSB , - .endian_rx =SSP_RX_LSB , - .data_size =SSP_DATA_BITS_8 , .rx_lev_trig =SSP_RX_4_OR_MORE_ELEM , .tx_lev_trig =SSP_TX_4_OR_MORE_EMPTY_LOC , - .clk_phase =SSP_CLK_FIRST_EDGE , - .clk_pol =SSP_CLK_POL_IDLE_LOW , .ctrl_len =SSP_BITS_8 , .wait_state =SSP_MWIRE_WAIT_ZERO , .duplex =SSP_MICROWIRE_CHANNEL_FULL_DUPLEX ,
@@ -239,6 +233,7 @@ static int __init phy3250_spi_board_register(void) .max_speed_hz = 5000000, .bus_num = 0, .chip_select = 0, + .mode = SPI_MODE_0, .platform_data = &eeprom, .controller_data = &spi0_chip_info, },
Signature · 1 line
1.7.2.2
PATCH 3/5 ARM: U300: spi->mode and spi_bits_per_words updates
In reply to [email protected]From: Kevin Wells <[email protected]>
Some of the fields in the pl022_chip_info structure used with the amba pl022 driver are no longer used. This patch removes those unused fields and changes the .mode flags in the spi_board_info structure to setup the correct SPI mode.
For the loopback driver, the bus_info pointer can be removed and the bits_per_word field can be used instead for setting the bus data width.
--- arch/arm/mach-u300/dummyspichip.c | 5 ++--- arch/arm/mach-u300/spi.c | 10 +--------- 2 files changed, 3 insertions(+), 12 deletions(-)
arch/arm/mach-u300/dummyspichip.c +2 -3
@@ -46,7 +46,6 @@ static ssize_t dummy_looptest(struct device *dev,* struct, this is just used here to alter the behaviour of the chip * in order to perform tests. */ -struct pl022_config_chip *chip_info = spi->controller_data;int status;u8 txbuf[14 ] = {0xDE ,0xAD ,0xBE ,0xEF ,0x2B ,0xAD ,0xCA ,0xFE ,0xBA ,0xBE ,0xB1 ,0x05 ,
@@ -72,7 +71,7 @@ static ssize_t dummy_looptest(struct device *dev,* Force chip to 8 bit mode * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! */ - chip_info->data_size =SSP_DATA_BITS_8 ; + spi->bits_per_word =8 ;/* You should NOT DO THIS EITHER */ spi->master->setup (spi);
@@ -159,7 +158,7 @@ static ssize_t dummy_looptest(struct device *dev,* Force chip to 16 bit mode * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! */ - chip_info->data_size =SSP_DATA_BITS_16 ; + spi->bits_per_word =16 ;/* You should NOT DO THIS EITHER */ spi->master->setup (spi);
arch/arm/mach-u300/spi.c +1 -9
@@ -30,8 +30,6 @@ static void select_dummy_chip(u32 chipselect) }struct pl022_config_chip dummy_chip_info = { -/* Nominally this is LOOPBACK_DISABLED, but this is our dummy chip! */ - .lbm =LOOPBACK_ENABLED ,/* * available POLLING_TRANSFER and INTERRUPT_TRANSFER, * DMA_TRANSFER does not work
@@ -42,14 +40,8 @@ struct pl022_config_chip dummy_chip_info = { .hierarchy = SSP_MASTER,/* 0 = drive TX even as slave, 1 = do not drive TX as slave */ .slave_tx_disable = 0, -/* LSB first */ - .endian_tx = SSP_TX_LSB, - .endian_rx = SSP_RX_LSB, - .data_size = SSP_DATA_BITS_8, /* used to be 12 in some default */ .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, - .clk_phase = SSP_CLK_SECOND_EDGE, - .clk_pol = SSP_CLK_POL_IDLE_LOW, .ctrl_len = SSP_BITS_12, .wait_state = SSP_MWIRE_WAIT_ZERO, .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
@@ -75,7 +67,7 @@ static struct spi_board_info u300_spi_devices[] = { .bus_num = 0, /* Only one bus on this chip */ .chip_select = 0, /* Means SPI_CS_HIGH, change if e.g low CS */ - .mode = 0, + .mode = SPI_MODE_1 | SPI_LSB_FIRST | SPI_LOOP, },#endif };
Signature · 1 line
1.7.2.2
PATCH 4/5 ARM: Ux500: Change SPI mode and remove unused fields
In reply to [email protected]From: Kevin Wells <[email protected]>
Some of the fields in the pl022_chip_info structure used with the amba pl022 driver are no longer used. This patch removes those unused fields and changes the .mode flags in the spi_board_info structure to setup the correct SPI mode.
--- arch/arm/mach-ux500/board-mop500.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
arch/arm/mach-ux500/board-mop500.c +1 -7
@@ -55,19 +55,13 @@ static void ab4500_spi_cs_control(u32 command) }struct pl022_config_chip ab4500_chip_info = { - .lbm =LOOPBACK_DISABLED , .com_mode =INTERRUPT_TRANSFER , .iface =SSP_INTERFACE_MOTOROLA_SPI ,/* we can act as master only */ .hierarchy =SSP_MASTER , .slave_tx_disable =0 , - .endian_rx =SSP_RX_MSB , - .endian_tx =SSP_TX_MSB , - .data_size =SSP_DATA_BITS_24 , .rx_lev_trig =SSP_RX_1_OR_MORE_ELEM , .tx_lev_trig =SSP_TX_1_OR_MORE_EMPTY_LOC , - .clk_phase =SSP_CLK_SECOND_EDGE , - .clk_pol =SSP_CLK_POL_IDLE_HIGH , .cs_control = ab4500_spi_cs_control, };
@@ -83,7 +77,7 @@ static struct spi_board_info u8500_spi_devices[] = { .max_speed_hz = 12000000, .bus_num = 0, .chip_select = 0, - .mode = SPI_MODE_0, + .mode = SPI_MODE_3, .irq = IRQ_DB8500_AB8500, }, };
Signature · 1 line
1.7.2.2
PATCH 5/5 spi: amba_pl022: Remove unused fields from pl022_config_chip
In reply to [email protected]From: Kevin Wells <[email protected]>
Some of the fields in the pl022_config_chip structure are no longer needed with the spi->mode updates. These fields have been removed.
--- include/linux/amba/pl022.h | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
include/linux/amba/pl022.h +0 -6
@@ -271,19 +271,13 @@ struct pl022_ssp_controller {*/ struct pl022_config_chip {struct device *dev; -enum ssp_loopback lbm;enum ssp_interface iface;enum ssp_hierarchy hierarchy;bool slave_tx_disable;struct ssp_clock_params clk_freq; -enum ssp_rx_endian endian_rx; -enum ssp_tx_endian endian_tx; -enum ssp_data_size data_size;enum ssp_mode com_mode;enum ssp_rx_level_trig rx_lev_trig;enum ssp_tx_level_trig tx_lev_trig; -enum ssp_spi_clk_phase clk_phase; -enum ssp_spi_clk_pol clk_pol;enum ssp_microwire_ctrl_len ctrl_len;enum ssp_microwire_wait_state wait_state;enum ssp_duplex duplex;
Signature · 1 line
1.7.2.2
Re: [PATCH 5/5] spi: amba_pl022: Remove unused fields from pl022_config_chip
2010/9/10 <[email protected]>:
Quoted 5 lines
From: Kevin Wells <[email protected]>
Some of the fields in the
pl022_config_chipstructure are no longer needed with thespi->modeupdates. These fields have been removed.
I think you have to do a more thorough patch:
drivers/spi/amba-pl022.c: In function 'verify_controller_parameters':drivers/spi/amba-pl022.c:1598: error: 'struct pl022_config_chip' has no member named 'lbm'drivers/spi/amba-pl022.c:1599: error: 'struct pl022_config_chip' has no member named 'lbm'drivers/spi/amba-pl022.c:1629: error: 'struct pl022_config_chip' has no member named 'endian_rx'
(... etc)
Yours,
Linus Walleij
Re: [PATCH 5/5] spi: amba_pl022: Remove unused fields from pl022_config_chip
2010/9/13 Linus Walleij <[email protected]>:
Quoted 1 line
I think you have to do a more thorough patch:
No, wait it's me. I have to have the old patch first and then this on top, sorry.
I'll test again...
Linus
2010/9/10 <[email protected]>:
Quoted 3 lines
This patch series updates drivers and platforms that depend on the
amba_pl022driver and use thepl022_config_chipstructure for setting up the SPI mode and data transfer width.
I get regressions from the ab8500-spi.c driver from this patch:
Quoted 4 lines
ssp-pl022 ssp0: ARM PL022 driver, device ID:
0x01080022
pl022: mapped registers from0x80002000tod0834000ab8500-spi spi0.0: unknown chip, revision:0x80
ab8500-spi: probe of spi0.0 failed with error -22
The 0x80 above used to be 0x00 before these patches. So all of a sudden bit 7 gets set...
I don't know why this happens, probably some flag that used to be set had not been properly propagated in the first patch to alter the AB8500 device registration?
Yours,
Linus Walleij
Quoted 14 lines
2010/9/10 <[email protected]>:
Quoted 3 lines
This patch series updates drivers and platforms that depend on the
amba_pl022driver and use thepl022_config_chipstructure for setting up the SPI mode and data transfer width.I get regressions from the
ab8500-spi.cdriver from this patch:Quoted 4 lines
ssp-pl022 ssp0: ARM PL022 driver, device ID:
0x01080022
pl022: mapped registers from0x80002000tod0834000ab8500-spi spi0.0: unknown chip, revision:0x80
ab8500-spi: probe of spi0.0 failed with error -22
Quoted 7 lines
The
0x80above used to be0x00before these patches. So all of a sudden bit 7 gets set...I don't know why this happens, probably some flag that used to be set had not been properly propagated in the first patch to alter the AB8500 device registration?
I found a bug in the SPI driver for the SPHA field. This would effect SPI mode 1/3 users. Can you please try it once more with the fix? (see fix in patch email)
I was hoping these changes would be very minor, but I have limited hardware to do SPI testing without resorting to loopback mode.
Thanks!
Kevin
Quoted 25 lines · On Fri, Sep 10, 2010 at 09:19:34AM -0700, wellsk40 at gmail.com wrote:
This patch series updates drivers and platforms that depend on the
amba_pl022driver and use thepl022_config_chipstructure for setting up the SPI mode and data transfer width.The SPI configuration (CPOL/CPHA mode, bit send order, data bits per word, and loopback mode) were previously setup as part of board specific data in the
pl022_config_chipstructure. This has been changed to now use the .mode field inspi_board_infostructure (or drivers that setup the mode). The SPI transfer's data width is now configured fromspi->bits_per_word.The SPI driver changes have been previously submitted to the SPI ML. This patch series need to be layered on that patch series.
These changes add or fix the .mode field in the plats/boards that use the driver (u300, ux500, lpc32xx). The patches also move the data width from the board specific area to the driver for mfd/ab8500. As the fields in the
pl022_config_chipstructure are no longer needed, they are removed in the last patch.These changes have been tested on the phy3250 platform (lpc32xx). I was able to test the ab8500 driver to some degree, but I only have a standard pl022. I am unable to test u300 and ux500 changes, but the u300 changes compiled fine.
Quoted 5 lines
[PATCH 1/5] mfd/ab8500: Setup SPI transfer for 24 bits [PATCH 2/5] ARM: LPC32XX: Add missing SPI mode and remove unused fields [PATCH 3/5] ARM: U300:
spi->modeandspi_bits_per_wordsupdates [PATCH 4/5] ARM: Ux500: Change SPI mode and remove unused fields [PATCH 5/5] spi:amba_pl022: Remove unused fields frompl022_config_chip
There are ordering issues with these patches and the patch they depend on. Basically, as-is it is not bisectable. The above platforms stop working after the SPI driver changes are applied, but before these patches are. You'll need to update the mode field for all the users in or before the SPI driver changes patch to preserve bisectability. Then you can have subsequent cleanup patches....
Or just squash all the patches into the SPI driver patch. I'd be okay with that in this case because the board changes are well contained and easy to understand.
g.