From: Ken Wilson <ken.wilson@opengear.com>
To: thomas.petazzoni@free-electrons.com
Cc: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
broonie@kernel.org, ezequiel.garcia@free-electrons.com,
gerg@uclinux.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
Ken Wilson <ken.wilson@opengear.com>
Subject: [PATCHv2 2/2] spi: orion: Add multiple chip select support to spi-orion
Date: Mon, 12 Jan 2015 13:14:00 +1000 [thread overview]
Message-ID: <1421032440-15335-3-git-send-email-ken.wilson@opengear.com> (raw)
In-Reply-To: <1421032440-15335-1-git-send-email-ken.wilson@opengear.com>
This commit adds support for multiple hardware chip selects to spi-orion.
The number of supported chip selects varies based on the SoC and pin
configuration, so it is set using the num-cs device tree binding.
Signed-off-by: Ken Wilson <ken.wilson@opengear.com>
---
Documentation/devicetree/bindings/spi/spi-orion.txt | 3 +++
drivers/spi/spi-orion.c | 17 +++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/spi/spi-orion.txt b/Documentation/devicetree/bindings/spi/spi-orion.txt
index 50c3a3d..0f8fd7e 100644
--- a/Documentation/devicetree/bindings/spi/spi-orion.txt
+++ b/Documentation/devicetree/bindings/spi/spi-orion.txt
@@ -6,6 +6,8 @@ Required properties:
- cell-index : Which of multiple SPI controllers is this.
Optional properties:
- interrupts : Is currently not used.
+- num-cs : The total number of chip selects used by this platform.
+ If unset, this defaults to 1.
Example:
spi@10600 {
@@ -15,5 +17,6 @@ Example:
cell-index = <0>;
reg = <0x10600 0x28>;
interrupts = <23>;
+ num-cs = <1>;
status = "disabled";
};
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index e6ac9d5..1c28152 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -28,7 +28,6 @@
/* Runtime PM autosuspend timeout: PM is fairly light on this driver */
#define SPI_AUTOSUSPEND_TIMEOUT 200
-#define ORION_NUM_CHIPSELECTS 1 /* only one slave is supported*/
#define ORION_SPI_WAIT_RDY_MAX_LOOP 2000 /* in usec */
#define ORION_SPI_IF_CTRL_REG 0x00
@@ -44,6 +43,10 @@
#define ARMADA_SPI_CLK_PRESCALE_MASK 0xDF
#define ORION_SPI_MODE_MASK (ORION_SPI_MODE_CPOL | \
ORION_SPI_MODE_CPHA)
+#define ORION_SPI_CS_MASK 0x1C
+#define ORION_SPI_CS_SHIFT 2
+#define ORION_SPI_CS(cs) ((cs << ORION_SPI_CS_SHIFT) & \
+ ORION_SPI_CS_MASK)
enum orion_spi_type {
ORION_SPI,
@@ -221,6 +224,10 @@ static void orion_spi_set_cs(struct spi_device *spi, bool enable)
orion_spi = spi_master_get_devdata(spi->master);
+ orion_spi_clrbits(orion_spi, ORION_SPI_IF_CTRL_REG, ORION_SPI_CS_MASK);
+ orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG,
+ ORION_SPI_CS(spi->chip_select));
+
/* Chip select logic is inverted from spi_set_cs */
if (!enable)
orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG, 0x1);
@@ -406,17 +413,23 @@ static int orion_spi_probe(struct platform_device *pdev)
master->bus_num = pdev->id;
if (pdev->dev.of_node) {
u32 cell_index;
+ u32 num_cs;
if (!of_property_read_u32(pdev->dev.of_node, "cell-index",
&cell_index))
master->bus_num = cell_index;
+
+ if (!of_property_read_u32(pdev->dev.of_node, "num_cs",
+ &num_cs))
+ master->num_chipselect = num_cs;
+ else
+ master->num_chipselect = 1;
}
/* we support only mode 0, and no options */
master->mode_bits = SPI_CPHA | SPI_CPOL;
master->set_cs = orion_spi_set_cs;
master->transfer_one = orion_spi_transfer_one;
- master->num_chipselect = ORION_NUM_CHIPSELECTS;
master->setup = orion_spi_setup;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->auto_runtime_pm = true;
--
2.0.0
next prev parent reply other threads:[~2015-01-12 3:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-12 3:13 [PATCHv2 0/2] spi: orion: Add multiple chip select support to spi-orion Ken Wilson
2015-01-12 3:13 ` [PATCHv2 1/2] spi: orion: Change spi-orion to use transfer_one() semantics for SPI transfers Ken Wilson
[not found] ` <1421032440-15335-2-git-send-email-ken.wilson-xg7Pnmy8KxlWk0Htik3J/w@public.gmane.org>
2015-01-14 17:22 ` Mark Brown
2015-01-12 3:14 ` Ken Wilson [this message]
2015-01-14 20:06 ` [PATCHv2 2/2] spi: orion: Add multiple chip select support to spi-orion Mark Brown
[not found] ` <20150114200626.GN3043-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-01-15 1:07 ` Ken Wilson
2015-01-15 11:22 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421032440-15335-3-git-send-email-ken.wilson@opengear.com \
--to=ken.wilson@opengear.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ezequiel.garcia@free-electrons.com \
--cc=galak@codeaurora.org \
--cc=gerg@uclinux.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).