spi: spi-fsl-spi: Make spi-fsl-spi usable in cpu mode outside of FSL SOC environments and add a grlib variant normally running on sparc
Subsystems (2)
v2 cover spi: spi-fsl-spi: Make spi-fsl-spi usable in cpu mode outside of FSL SOC environments and add a grlib variant normally running on sparc
This makes the cpu mode of the driver available outside of an FSL SOC and even powerpc environment. Furthermore, this adds support for the mostly register-compatible SPICTRL core from the GRLIB VHDL IP core library normally running on SPARC.
This effort is split up in several patches for clarity of what is being changed. Patches 3-5 prepares for the introduction of the GRLIB SPICTRL functionality in patch 6.
To use what is introduced right away they could eventually be merged:
Patch A: patch 1
Patch B: patch 2
Patch C: patches 3-6 merged
Patch D: patch 7
Patch 1 makes the driver compileable and presumably useable outside of FSL SOC and powerpc environments (SPARC in particular)
Patch 2 fixes a bug that can happen when a device uses SPI_CS_HIGH
Patches 3-6 makes the driver working for GRLIB SPICTRL cores that has the built in slave select register and that uses that exclusively for chipselects.
Patch 7 introduces gpio support for GRLIB SPICTRL cores. That patch (and that patch only) relies upon the "of, of_gpio, of_spi: Fix and improve of_parse_phandle_with_args, of_gpio_named_count and of_spi_register_master" patchset - https://lkml.org/lkml/2013/1/29/308
The GRLIB type has been tested under sparc. The FSL type has been compile tested in powerpc, arm and x86 environments. It would be great if someone with an FSL board could test this out.
One could argue that it would be better to add the GRLIB variant as a mode flag in of_mpc8xxx_spi_probe instead of using a new type field, but that would require to add a flag for this core in include/linux/fsl_devices.h which does not feel right given that this core is not part of an FSL device.
Andreas Larsson (7):
spi: spi-fsl-spi: Make driver usable in CPU mode outside of an
FSL_SOC environment
spi: spi-fsl-spi: Make sure in spi_fsl_setup that chipselect becomes
inactive
spi: spi-fsl-spi: Move setting non-zero tx and rx shifts to a
function accessed by a function pointer
spi: spi-fsl-spi: Introduce a type for the driver
spi: spi-fsl-spi: Add support for setting a maximum number of bits
per word
spi: spi-fsl-spi: Add support for Aeroflex Gaisler GRLIB cores
normally running on SPARC
spi: spi-fsl-spi: Add support for gpio chipselects for GRLIB type
cores
Documentation/devicetree/bindings/spi/fsl-spi.txt | 3 +- .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/spi/Kconfig | 11 +- drivers/spi/Makefile | 1 + drivers/spi/spi-fsl-cpm.c | 387 +++++++++++++ drivers/spi/spi-fsl-cpm.h | 43 ++ drivers/spi/spi-fsl-lib.c | 8 + drivers/spi/spi-fsl-lib.h | 15 +- drivers/spi/spi-fsl-spi.c | 610 ++++++-------------- drivers/spi/spi-fsl-spi.h | 72 +++ 10 files changed, 725 insertions(+), 426 deletions(-) create mode 100644 drivers/spi/spi-fsl-cpm.c create mode 100644 drivers/spi/spi-fsl-cpm.h create mode 100644 drivers/spi/spi-fsl-spi.h
PATCH v2 1/7 spi: spi-fsl-spi: Make driver usable in CPU mode outside of an FSL_SOC environment
This makes the spi-fsl-spi driver usable in CPU mode outside of an FSL_SOC and even an powerpc environment by moving CPM mode functionality to a separate file that is only compiled and linked in an FSL_SOC environment and adding some ifdefs to hide types and functions or provide alternatives.
For devicetree probing a "clock-frequency" property is used for clock frequency instead of calls to FSL_SOC-specific functions.
---
This introduces a lot of line changes, but to illustrate that large parts of is just moving between files you can run the following script at this commit standing in the source root directory:
#!/bin/bash
ORIG=$(mktemp)
CPM=$(mktemp)
git show HEAD~:drivers/spi/spi-fsl-spi.c > $ORIG
sed -n "42,+8 p" $ORIG >> $CPM
sed -n "90,+12 p" $ORIG >> $CPM
sed -n "122,+12 p" $ORIG | sed 's/^\t//' >> $CPM
sed -n "298,+105 p" $ORIG >> $CPM
sed -n "571,+23 p" $ORIG >> $CPM
sed -n "649,+190 p" $ORIG >> $CPM
diff -u $CPM drivers/spi/spi-fsl-cpm.c
sed -n "51,+38 p" $ORIG | diff -u -- - drivers/spi/spi-fsl-spi.h
rm $ORIG $CPM
Documentation/devicetree/bindings/spi/fsl-spi.txt | 1 + drivers/spi/Kconfig | 7 +- drivers/spi/Makefile | 1 + drivers/spi/spi-fsl-cpm.c | 387 +++++++++++++++++++ drivers/spi/spi-fsl-cpm.h | 43 +++ drivers/spi/spi-fsl-lib.c | 8 + drivers/spi/spi-fsl-lib.h | 6 +- drivers/spi/spi-fsl-spi.c | 411 +-------------------- drivers/spi/spi-fsl-spi.h | 61 +++ 9 files changed, 520 insertions(+), 405 deletions(-) create mode 100644 drivers/spi/spi-fsl-cpm.c create mode 100644 drivers/spi/spi-fsl-cpm.h create mode 100644 drivers/spi/spi-fsl-spi.h
Documentation/devicetree/bindings/spi/fsl-spi.txt +1 -0
@@ -14,6 +14,7 @@ Required properties: controller you have. - interrupt-parent : the phandle for the interrupt controller that services interrupts for this device. +- clock-frequency : input clock frequency to non FSL_SOC cores Optional properties: - gpios : specifies the gpio pins to be used for chipselects.
drivers/spi/Kconfig +6 -1
@@ -218,12 +218,17 @@ config SPI_MPC512x_PSC config SPI_FSL_LIB tristate + depends on OF + +config SPI_FSL_CPM + tristate depends on FSL_SOC config SPI_FSL_SPI bool "Freescale SPI controller" - depends on FSL_SOC + depends on OF select SPI_FSL_LIB + select SPI_FSL_CPM if FSL_SOC help This enables using the Freescale SPI controllers in master mode. MPC83xx platform uses the controller in cpu mode or CPM/QE mode.
drivers/spi/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_SPI_DW_PCI) += spi-dw-midpci.o spi-dw-midpci-objs := spi-dw-pci.o spi-dw-mid.o obj-$(CONFIG_SPI_EP93XX) += spi-ep93xx.o obj-$(CONFIG_SPI_FALCON) += spi-falcon.o +obj-$(CONFIG_SPI_FSL_CPM) += spi-fsl-cpm.o obj-$(CONFIG_SPI_FSL_LIB) += spi-fsl-lib.o obj-$(CONFIG_SPI_FSL_ESPI) += spi-fsl-espi.o obj-$(CONFIG_SPI_FSL_SPI) += spi-fsl-spi.o
drivers/spi/spi-fsl-cpm.c new file +387 -0
387 lines not on this page · raw message
drivers/spi/spi-fsl-cpm.h new file +43 -0
43 lines not on this page · raw message
drivers/spi/spi-fsl-lib.c +8 -0
@@ -23,7 +23,9 @@#include <linux/mm.h> #include <linux/of_platform.h> #include <linux/spi/spi.h> +#ifdef CONFIG_FSL_SOC #include <sysdev/fsl_soc.h> +#endif #include "spi-fsl-lib.h"
@@ -208,6 +210,7 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev)/* Allocate bus num dynamically. */ pdata->bus_num =-1 ; +#ifdef CONFIG_FSL_SOC /* SPI controller is either clocked from QE or SoC clock. */ pdata->sysclk =get_brgfreq ();if (pdata->sysclk ==-1 ) {
@@ -217,6 +220,11 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) goto err; } } +#else + ret =of_property_read_u32 (np,"clock-frequency" , &pdata->sysclk); +if (ret) + goto err; +#endif prop =of_get_property (np,"mode" ,NULL );if (prop && !strcmp (prop,"cpu-qe" ))
drivers/spi/spi-fsl-lib.h +4 -2
@@ -34,8 +34,10 @@ struct mpc8xxx_spi {int subblock;struct spi_pram __iomem *pram; +#ifdef CONFIG_FSL_SOC struct cpm_buf_desc __iomem *tx_bd;struct cpm_buf_desc __iomem *rx_bd; +#endif struct spi_transfer *xfer_in_progress;
@@ -87,12 +89,12 @@ struct spi_mpc8xxx_cs {static inline void mpc8xxx_spi_write_reg (__be32 __iomem *reg,u32 val) { -out_be32 (reg, val); +iowrite32be (val, reg); }static inline u32 mpc8xxx_spi_read_reg (__be32 __iomem *reg) { -return in_be32 (reg); +return ioread32be (reg); }struct mpc8xxx_spi_probe_info {
drivers/spi/spi-fsl-spi.c +9 -402
461 lines not on this page · raw message
drivers/spi/spi-fsl-spi.h new file +61 -0
61 lines not on this page · raw message
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
PATCH v2 2/7 spi: spi-fsl-spi: Make sure in spi_fsl_setup that chipselect becomes inactive
In reply to Andreas LarssonThis is needed for a device in SPI_CS_HIGH mode that otherwise could start out active for the first transaction.
--- drivers/spi/spi-fsl-spi.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/spi/spi-fsl-spi.c +4 -0
@@ -387,6 +387,10 @@ static int fsl_spi_setup(struct spi_device *spi) cs->hw_mode = hw_mode;/* Restore settings */ return retval; } + +/* Initialize chipselect - might be active for SPI_CS_HIGH mode */ +fsl_spi_chipselect (spi,BITBANG_CS_INACTIVE ); +return 0 ; }
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
PATCH v2 3/7 spi: spi-fsl-spi: Move setting non-zero tx and rx shifts to a function accessed by a function pointer
In reply to Andreas Larsson--- drivers/spi/spi-fsl-lib.h | 5 ++++ drivers/spi/spi-fsl-spi.c | 51 +++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 20 deletions(-)
drivers/spi/spi-fsl-lib.h +5 -0
@@ -69,6 +69,11 @@ struct mpc8xxx_spi {unsigned int flags; +#ifdef CONFIG_SPI_FSL_SPI +void (*set_shifts)(u32 *rx_shift,u32 *tx_shift, +int bits_per_word,int msb_first); +#endif +struct workqueue_struct *workqueue;struct work_struct work;
drivers/spi/spi-fsl-spi.c +31 -20
78 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v2 4/7 spi: spi-fsl-spi: Introduce a type for the driver
In reply to Andreas LarssonFor being able to distinguishing between the regular type of cores and others with different entries in of_fsl_spi_match.
--- drivers/spi/spi-fsl-lib.h | 2 ++ drivers/spi/spi-fsl-spi.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-lib.h +2 -0
@@ -70,6 +70,8 @@ struct mpc8xxx_spi {unsigned int flags;#ifdef CONFIG_SPI_FSL_SPI +int type; +void (*set_shifts)(u32 *rx_shift,u32 *tx_shift,int bits_per_word,int msb_first);#endif
drivers/spi/spi-fsl-spi.c +32 -7
@@ -39,6 +39,37 @@#include "spi-fsl-cpm.h" #include "spi-fsl-spi.h" +#define TYPE_FSL 0 + +struct fsl_spi_match_data { +int type; +}; + +static struct fsl_spi_match_data of_fsl_spi_fsl_config = { + .type =TYPE_FSL , +}; + +static struct of_device_id of_fsl_spi_match[] = { + { + .compatible ="fsl,spi" , + .data = &of_fsl_spi_fsl_config, + }, + {} +}; +MODULE_DEVICE_TABLE (of, of_fsl_spi_match); + +static int fsl_spi_get_type (struct device *dev) +{ +const struct of_device_id *match; + +if (dev->of_node) { + match =of_match_node (of_fsl_spi_match, dev->of_node); +if (match && match->data) +return ((struct fsl_spi_match_data *)match->data)->type; + } +return TYPE_FSL ; +} +static void fsl_spi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -489,7 +520,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; mpc8xxx_spi->spi_remove = fsl_spi_remove; - + mpc8xxx_spi->type =fsl_spi_get_type (dev); ret =fsl_spi_cpm_init (mpc8xxx_spi);if (ret)
@@ -716,12 +747,6 @@ static int of_fsl_spi_remove(struct platform_device *ofdev)return 0 ; } -static const struct of_device_id of_fsl_spi_match[] = { - { .compatible ="fsl,spi" }, - {} -}; -MODULE_DEVICE_TABLE (of, of_fsl_spi_match); -static struct platform_driver of_fsl_spi_driver = { .driver = { .name ="fsl_spi" ,
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
PATCH v2 5/7 spi: spi-fsl-spi: Add support for setting a maximum number of bits per word
In reply to Andreas Larsson--- drivers/spi/spi-fsl-lib.h | 1 + drivers/spi/spi-fsl-spi.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletions(-)
drivers/spi/spi-fsl-lib.h +1 -0
@@ -71,6 +71,7 @@ struct mpc8xxx_spi {#ifdef CONFIG_SPI_FSL_SPI int type; +u8 max_bits_per_word;void (*set_shifts)(u32 *rx_shift,u32 *tx_shift,int bits_per_word,int msb_first);
drivers/spi/spi-fsl-spi.c +7 -1
@@ -213,7 +213,8 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,/* Make sure its a bit width we support [4..16, 32] */ if ((bits_per_word <4 ) - || ((bits_per_word >16 ) && (bits_per_word !=32 ))) + || ((bits_per_word >16 ) && (bits_per_word !=32 )) + || (bits_per_word > mpc8xxx_spi->max_bits_per_word))return -EINVAL ;if (!hz)
@@ -520,6 +521,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; mpc8xxx_spi->spi_remove = fsl_spi_remove; + mpc8xxx_spi->max_bits_per_word =32 ; mpc8xxx_spi->type =fsl_spi_get_type (dev); ret =fsl_spi_cpm_init (mpc8xxx_spi);
@@ -557,6 +559,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev,/* Enable SPI interface */ regval = pdata->initial_spmode |SPMODE_INIT_VAL |SPMODE_ENABLE ; +if (mpc8xxx_spi->max_bits_per_word <8 ) { + regval &= ~SPMODE_LEN (0xF ); + regval |=SPMODE_LEN (mpc8xxx_spi->max_bits_per_word -1 ); + }if (mpc8xxx_spi->flags &SPI_QE_CPU_MODE ) regval |=SPMODE_OP ;
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
PATCH v2 6/7 spi: spi-fsl-spi: Add support for Aeroflex Gaisler GRLIB cores normally running on SPARC
In reply to Andreas LarssonThis adds support for the mostly register-compatible SPICTRL cores from the GRLIB VHDL IP core library from Aeroflex Gaisler. They are normally running on SPARC. A different entry in of_fsl_spi_match matches this core and indicates a different hardware type that is used to set up different function pointers and special cases.
The GRLIB core operates in cpu mode. The number of bits per word might be limited. There might be native chipselects selected via a slave select register. These differences to the FSL type cores, if present, are indicated by a capabilities register. Other register and function differences exists but are not relevant to the driver.
--- Documentation/devicetree/bindings/spi/fsl-spi.txt | 2 +- .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/spi/Kconfig | 4 +- drivers/spi/spi-fsl-spi.c | 98 +++++++++++++++++--- drivers/spi/spi-fsl-spi.h | 13 +++- 5 files changed, 103 insertions(+), 15 deletions(-)
Documentation/devicetree/bindings/spi/fsl-spi.txt +1 -1
@@ -4,7 +4,7 @@ Required properties: - cell-index : QE SPI subblock index. 0: QE subblock SPI1 1: QE subblock SPI2 -- compatible : should be "fsl,spi". +- compatible : should be "fsl,spi" or "aeroflexgaisler,spictrl". - mode : the SPI operation mode, it can be "cpu" or "cpu-qe". - reg : Offset and length of the register set for the device - interrupts : <a b> where a is the interrupt number and b is a
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -5,6 +5,7 @@ using them to avoid name-space collisions. ad Avionic Design GmbH adi Analog Devices, Inc. +aeroflexgaisler Aeroflex Gaisler AB ak Asahi Kasei Corp. amcc Applied Micro Circuits Corporation (APM, formally AMCC) apm Applied Micro Circuits Corporation (APM)
drivers/spi/Kconfig +3 -1
@@ -225,7 +225,7 @@ config SPI_FSL_CPM depends on FSL_SOC config SPI_FSL_SPI - bool "Freescale SPI controller" + bool "Freescale SPI controller and Aeroflex Gaisler GRLIB SPI controller" depends on OF select SPI_FSL_LIB select SPI_FSL_CPM if FSL_SOC
@@ -233,6 +233,8 @@ config SPI_FSL_SPI This enables using the Freescale SPI controllers in master mode. MPC83xx platform uses the controller in cpu mode or CPM/QE mode. MPC8569 uses the controller in QE mode, MPC8610 in cpu mode. + This also enables using the Aeroflex Gaisler GRLIB SPI controller in + master mode. config SPI_FSL_ESPI bool "Freescale eSPI controller"
drivers/spi/spi-fsl-spi.c +86 -12
173 lines not on this page · raw message
drivers/spi/spi-fsl-spi.h +12 -1
@@ -10,6 +10,10 @@* Copyright (c) 2009 MontaVista Software, Inc. * Author: Anton Vorontsov <[email protected]> * +* GRLIB support: +* Copyright (c) 2012 Aeroflex Gaisler AB. +* Author: Andreas Larsson <andreas-FkzTOoA/[email protected]> +* * 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
@@ -21,13 +25,15 @@/* SPI Controller registers */ struct fsl_spi_reg { -u8 res1[0x20 ]; +__be32 cap;/* TYPE_GRLIB specific */ +u8 res1[0x1C ];__be32 mode;__be32 event;__be32 mask;__be32 command;__be32 transmit;__be32 receive; +__be32 slvsel;/* TYPE_GRLIB specific */ };/* SPI Controller mode register definitions */
@@ -43,6 +49,11 @@ struct fsl_spi_reg {#define SPMODE_OP (1 << 14)#define SPMODE_CG (x) ((x) << 7) +/* TYPE_GRLIB SPI Controller capability register definitions */ +#define SPCAP_SSEN (x) (((x) >> 16) & 0x1) +#define SPCAP_SSSZ (x) (((x) >> 24) & 0xff) +#define SPCAP_MAXWLEN (x) (((x) >> 20) & 0xf) +/* * Default for SPI Mode: * SPI MODE 0 (inactive low, phase middle, MSB, 8-bit length, slow clk
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
PATCH v2 7/7 spi: spi-fsl-spi: Add support for gpio chipselects for GRLIB type cores
In reply to Andreas LarssonThis relies upon of_spi_register_master to find out which gpios to use.
--- drivers/spi/spi-fsl-lib.h | 1 + drivers/spi/spi-fsl-spi.c | 53 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-lib.h +1 -0
@@ -71,6 +71,7 @@ struct mpc8xxx_spi {#ifdef CONFIG_SPI_FSL_SPI int type; +int native_chipselects;u8 max_bits_per_word; void (*set_shifts)(u32 *rx_shift, u32 *tx_shift,
drivers/spi/spi-fsl-spi.c +47 -6
92 lines not on this page · raw message
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
PATCH RESEND v2 4/7 spi: spi-fsl-spi: Introduce a type for the driver
In reply to Andreas LarssonFor being able to distinguishing between the regular type of cores and others with different entries in of_fsl_spi_match.
---
[Resent, as the mail for patch 4 seems to have been lost somehow]
drivers/spi/spi-fsl-lib.h | 2 ++ drivers/spi/spi-fsl-spi.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-lib.h +2 -0
@@ -70,6 +70,8 @@ struct mpc8xxx_spi {unsigned int flags;#ifdef CONFIG_SPI_FSL_SPI +int type; +void (*set_shifts)(u32 *rx_shift,u32 *tx_shift,int bits_per_word,int msb_first);#endif
drivers/spi/spi-fsl-spi.c +32 -7
@@ -39,6 +39,37 @@#include "spi-fsl-cpm.h" #include "spi-fsl-spi.h" +#define TYPE_FSL 0 + +struct fsl_spi_match_data { +int type; +}; + +static struct fsl_spi_match_data of_fsl_spi_fsl_config = { + .type =TYPE_FSL , +}; + +static struct of_device_id of_fsl_spi_match[] = { + { + .compatible ="fsl,spi" , + .data = &of_fsl_spi_fsl_config, + }, + {} +}; +MODULE_DEVICE_TABLE (of, of_fsl_spi_match); + +static int fsl_spi_get_type (struct device *dev) +{ +const struct of_device_id *match; + +if (dev->of_node) { + match =of_match_node (of_fsl_spi_match, dev->of_node); +if (match && match->data) +return ((struct fsl_spi_match_data *)match->data)->type; + } +return TYPE_FSL ; +} +static void fsl_spi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -489,7 +520,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; mpc8xxx_spi->spi_remove = fsl_spi_remove; - + mpc8xxx_spi->type =fsl_spi_get_type (dev); ret =fsl_spi_cpm_init (mpc8xxx_spi);if (ret)
@@ -716,12 +747,6 @@ static int of_fsl_spi_remove(struct platform_device *ofdev)return 0 ; } -static const struct of_device_id of_fsl_spi_match[] = { - { .compatible ="fsl,spi" }, - {} -}; -MODULE_DEVICE_TABLE (of, of_fsl_spi_match); -static struct platform_driver of_fsl_spi_driver = { .driver = { .name ="fsl_spi" ,
Signature · 8 lines
1.7.0.4 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
Re: [PATCH v2 7/7] spi: spi-fsl-spi: Add support for gpio chipselects for GRLIB type cores
In reply to Andreas LarssonQuoted 7 lines · Andreas Larsson
This relies upon
of_spi_register_masterto find out which gpios to use.Signed-off-by Andreas Larsson <[email protected]>--- drivers/spi/spi-fsl-lib.h | 1 + drivers/spi/spi-fsl-spi.c | 53 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 6 deletions(-)
Just a couple of minor nits...
Quoted 17 lines
drivers/spi/spi-fsl-lib.h +1
-0@@ -71,6 +71,7 @@ struct mpc8xxx_spi {#ifdef CONFIG_SPI_FSL_SPI int type; +int native_chipselects;u8 max_bits_per_word; void (*set_shifts)(u32 *rx_shift, u32 *tx_shift,drivers/spi/spi-fsl-spi.c +0
-0
drivers/spi/spi-fsl-spi.c static int fsl_spi_setup(struct spi_device *spi) · line 421
Quoted 5 lines
drivers/spi/spi-fsl-spi.c +1
-1@@ -418,7 +418,7 @@ static int fsl_spi_setup(struct spi_device *spi) {struct mpc8xxx_spi *mpc8xxx_spi;struct fsl_spi_reg *reg_base; -int retval; +int retval, desel;
We don't usually place variable declarations on the same line, unless the variables are closely related.
drivers/spi/spi-fsl-spi.c static int fsl_spi_setup(struct spi_device *spi) · line 460
Quoted 9 lines
drivers/spi/spi-fsl-spi.c +2
-0u32 hw_mode;struct spi_mpc8xxx_cs *cs = spi->controller_state;@@ -456,12 +456,45 @@ static int fsl_spi_setup(struct spi_device *spi)return retval; } +if (mpc8xxx_spi->type ==TYPE_GRLIB ) { +if (gpio_is_valid (spi->cs_gpio)) {
<- You can place the 'int desel;' here, limiting the visibility for it.
drivers/spi/spi-fsl-spi.c static int fsl_spi_setup(struct spi_device *spi) · line 472
Quoted 12 lines
drivers/spi/spi-fsl-spi.c +12
-0+ retval =gpio_request (spi->cs_gpio, +dev_name (&spi->dev)); +if (retval) +return retval; + + desel = !(spi->mode &SPI_CS_HIGH ); + desel ^= !!(spi->cs_gpio_flags &OF_GPIO_ACTIVE_LOW ); + retval =gpio_direction_output (spi->cs_gpio, desel); +if (retval) { +gpio_free (spi->cs_gpio); +return retval; + }
Thanks,
Anton
Quoted 4 lines · Andreas Larsson
This makes the cpu mode of the driver available outside of an FSL SOC and even powerpc environment. Furthermore, this adds support for the mostly register-compatible SPICTRL core from the GRLIB VHDL IP core library normally running on SPARC.
The patches look clean and neat, I don't see anything obviously wrong with them... so,
Thanks!
Anton
Re: [PATCH v2 7/7] spi: spi-fsl-spi: Add support for gpio chipselects for GRLIB type cores
In reply to Anton VorontsovQuoted 11 lines · Anton Vorontsov
drivers/spi/spi-fsl-spi.c static int fsl_spi_setup(struct spi_device *spi) · line 421
Quoted 3 lines · Andreas Larsson
struct
fsl_spi_reg*reg_base;drivers/spi/spi-fsl-spi.c +1
-1-int retval; +int retval, desel;We don't usually place variable declarations on the same line, unless the variables are closely related.
Quoted 3 lines
u32 hw_mode; struct spi_mpc8xxx_cs *cs = spi->controller_state;
Quoted 8 lines
drivers/spi/spi-fsl-spi.c static int fsl_spi_setup(struct spi_device *spi) · line 460
Quoted 6 lines
drivers/spi/spi-fsl-spi.c +2
-0@@ -456,12 +456,45 @@ static int fsl_spi_setup(struct spi_device *spi)return retval; } +if (mpc8xxx_spi->type ==TYPE_GRLIB ) { +if (gpio_is_valid (spi->cs_gpio)) {<- You can place the 'int desel;' here, limiting the visibility for it.
Thanks for the feedback!
I'll put that in v3. This last patch needs to wait for the other patchset I mentioned anyway.
Cheers,
Andreas
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
Re: [PATCH v2 7/7] spi: spi-fsl-spi: Add support for gpio chipselects for GRLIB type cores
In reply to Anton VorontsovQuoted 22 lines · Anton Vorontsov
Quoted 7 lines · Andreas Larsson
This relies upon
of_spi_register_masterto find out which gpios to use.Signed-off-by Andreas Larsson <andreas-FkzTOoA/[email protected]>--- drivers/spi/spi-fsl-lib.h | 1 + drivers/spi/spi-fsl-spi.c | 53 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 6 deletions(-)Just a couple of minor nits...
Quoted 11 lines
drivers/spi/spi-fsl-lib.h +1
-0@@ -71,6 +71,7 @@ struct mpc8xxx_spi {#ifdef CONFIG_SPI_FSL_SPI int type; +int native_chipselects;u8 max_bits_per_word;
Quoted 14 lines
drivers/spi/spi-fsl-spi.c static int fsl_spi_setup(struct spi_device *spi) · line 421
Quoted 11 lines
drivers/spi/spi-fsl-lib.h +0
-0void (*set_shifts)(u32 *rx_shift, u32 *tx_shift,drivers/spi/spi-fsl-spi.c +1
-1@@ -418,7 +418,7 @@ static int fsl_spi_setup(struct spi_device *spi) {struct mpc8xxx_spi *mpc8xxx_spi;struct fsl_spi_reg *reg_base; -int retval; +int retval, desel;We don't usually place variable declarations on the same line, unless the variables are closely related.
That's not something I've ever heard before. I certainly won't reject a patch over it.
g.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb