Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1189864 > unrolled thread

[RESEND][PATCH 0/4] spi: davinci: Improve prescaler limit support

Started byFranklin S Cooper Jr <fcooper@ti.com>
First post2015-07-22 14:40 +0200
Last post2015-07-24 14:00 +0200
Articles 8 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [RESEND][PATCH 0/4] spi: davinci: Improve prescaler limit support Franklin S Cooper Jr <fcooper@ti.com> - 2015-07-22 14:40 +0200
    [RESEND][PATCH 1/4] spi: davinci: Set prescale value based on register value Franklin S Cooper Jr <fcooper@ti.com> - 2015-07-22 14:40 +0200
    [RESEND][PATCH 4/4] ARM: dts: keystone: Add ti,keystone-spi for SPI Franklin S Cooper Jr <fcooper@ti.com> - 2015-07-22 14:40 +0200
      Re: [RESEND][PATCH 4/4] ARM: dts: keystone: Add ti,keystone-spi for  SPI santosh shilimkar <santosh.shilimkar@oracle.com> - 2015-07-22 18:20 +0200
    [RESEND][PATCH 3/4] ARM: davinci: Set proper SPI prescale limit value Franklin S Cooper Jr <fcooper@ti.com> - 2015-07-22 14:40 +0200
      Re: [RESEND][PATCH 3/4] ARM: davinci: Set proper SPI prescale limit  value Sekhar Nori <nsekhar@ti.com> - 2015-07-24 14:00 +0200
    [RESEND][PATCH 2/4] spi: davinci: Choose correct pre-scaler limit based on SOC Franklin S Cooper Jr <fcooper@ti.com> - 2015-07-22 14:40 +0200
      Re: [RESEND][PATCH 2/4] spi: davinci: Choose correct pre-scaler limit  based on SOC Sekhar Nori <nsekhar@ti.com> - 2015-07-24 14:00 +0200

#1189864 — [RESEND][PATCH 0/4] spi: davinci: Improve prescaler limit support

FromFranklin S Cooper Jr <fcooper@ti.com>
Date2015-07-22 14:40 +0200
Subject[RESEND][PATCH 0/4] spi: davinci: Improve prescaler limit support
Message-ID<pP1tv-6UG-1@gated-at.bofh.it>
Currently the prescale limit is treated as one size fits all value even
though there are differences depending on the SOC. This patchset insures
that the proper prescale limit is used for each platform/SoC.

Franklin S Cooper Jr (4):
  spi: davinci: Set prescale value based on register value
  spi: davinci: Choose correct pre-scaler limit based on SOC
  ARM: davinci: Set proper SPI prescale limit value
  ARM: dts: keystone: Add ti,keystone-spi for SPI

 .../devicetree/bindings/spi/spi-davinci.txt        |  2 +
 arch/arm/boot/dts/keystone.dtsi                    |  6 +--
 arch/arm/mach-davinci/devices-da8xx.c              |  2 +
 arch/arm/mach-davinci/dm355.c                      |  1 +
 arch/arm/mach-davinci/dm365.c                      |  1 +
 drivers/spi/spi-davinci.c                          | 50 +++++++++++++++++-----
 include/linux/platform_data/spi-davinci.h          |  1 +
 7 files changed, 50 insertions(+), 13 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1189865 — [RESEND][PATCH 1/4] spi: davinci: Set prescale value based on register value

FromFranklin S Cooper Jr <fcooper@ti.com>
Date2015-07-22 14:40 +0200
Subject[RESEND][PATCH 1/4] spi: davinci: Set prescale value based on register value
Message-ID<pP1tv-6UG-5@gated-at.bofh.it>
In reply to#1189864
Within davinci_spi_get_prescale() the prescale has two meanings. First one
being the calculated prescale value and then at the end translates it to the
prescale value that will be written to the SPI register.

At first glance this can be confusing especially when comparing the minimum
prescale value against what is seen in the TRM.

To simplify things make it clear that the calculated prescale value will always
be based on the value that will be written into the SPI register.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
 drivers/spi/spi-davinci.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 987afeb..b4605c4 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -255,7 +255,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
  * This function calculates the prescale value that generates a clock rate
  * less than or equal to the specified maximum.
  *
- * Returns: calculated prescale - 1 for easy programming into SPI registers
+ * Returns: calculated prescale value for easy programming into SPI registers
  * or negative error number if valid prescalar cannot be updated.
  */
 static inline int davinci_spi_get_prescale(struct davinci_spi *dspi,
@@ -263,12 +263,13 @@ static inline int davinci_spi_get_prescale(struct davinci_spi *dspi,
 {
 	int ret;
 
-	ret = DIV_ROUND_UP(clk_get_rate(dspi->clk), max_speed_hz);
+	/* Subtract 1 to match what will be programmed into SPI register. */
+	ret = DIV_ROUND_UP(clk_get_rate(dspi->clk), max_speed_hz) - 1;
 
-	if (ret < 1 || ret > 256)
+	if (ret < 0 || ret > 255)
 		return -EINVAL;
 
-	return ret - 1;
+	return ret;
 }
 
 /**
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1189867 — [RESEND][PATCH 4/4] ARM: dts: keystone: Add ti,keystone-spi for SPI

FromFranklin S Cooper Jr <fcooper@ti.com>
Date2015-07-22 14:40 +0200
Subject[RESEND][PATCH 4/4] ARM: dts: keystone: Add ti,keystone-spi for SPI
Message-ID<pP1tw-6UG-13@gated-at.bofh.it>
In reply to#1189864
Add ti,keystone-spi to the compatible field for the SPI node. This new
entry insures that the proper prescaler limit is used for keystone devices

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
 arch/arm/boot/dts/keystone.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/keystone.dtsi b/arch/arm/boot/dts/keystone.dtsi
index c06542b..ea2e1cd 100644
--- a/arch/arm/boot/dts/keystone.dtsi
+++ b/arch/arm/boot/dts/keystone.dtsi
@@ -136,7 +136,7 @@
 		};
 
 		spi0: spi@21000400 {
-			compatible = "ti,dm6441-spi";
+			compatible = "ti,keystone-spi", "ti,dm6441-spi";
 			reg = <0x21000400 0x200>;
 			num-cs = <4>;
 			ti,davinci-spi-intr-line = <0>;
@@ -147,7 +147,7 @@
 		};
 
 		spi1: spi@21000600 {
-			compatible = "ti,dm6441-spi";
+			compatible = "ti,keystone-spi", "ti,dm6441-spi";
 			reg = <0x21000600 0x200>;
 			num-cs = <4>;
 			ti,davinci-spi-intr-line = <0>;
@@ -158,7 +158,7 @@
 		};
 
 		spi2: spi@21000800 {
-			compatible = "ti,dm6441-spi";
+			compatible = "ti,keystone-spi", "ti,dm6441-spi";
 			reg = <0x21000800 0x200>;
 			num-cs = <4>;
 			ti,davinci-spi-intr-line = <0>;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1190087 — Re: [RESEND][PATCH 4/4] ARM: dts: keystone: Add ti,keystone-spi for SPI

Fromsantosh shilimkar <santosh.shilimkar@oracle.com>
Date2015-07-22 18:20 +0200
SubjectRe: [RESEND][PATCH 4/4] ARM: dts: keystone: Add ti,keystone-spi for SPI
Message-ID<pP4Up-3yc-3@gated-at.bofh.it>
In reply to#1189867
On 7/22/2015 5:32 AM, Franklin S Cooper Jr wrote:
> Add ti,keystone-spi to the compatible field for the SPI node. This new
> entry insures that the proper prescaler limit is used for keystone devices
>
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> ---
Once the binding and driver makes it, I can pick this up.
Keep me posted. Thanks !!

Regards,
Santosh

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1189868 — [RESEND][PATCH 3/4] ARM: davinci: Set proper SPI prescale limit value

FromFranklin S Cooper Jr <fcooper@ti.com>
Date2015-07-22 14:40 +0200
Subject[RESEND][PATCH 3/4] ARM: davinci: Set proper SPI prescale limit value
Message-ID<pP1tw-6UG-15@gated-at.bofh.it>
In reply to#1189864
SPI Davinci driver has been updated to allow SOCs to specify their minimum
prescale value. Update the various SOCs board files that use this driver with
their proper prescaler limit.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
 arch/arm/mach-davinci/devices-da8xx.c | 2 ++
 arch/arm/mach-davinci/dm355.c         | 1 +
 arch/arm/mach-davinci/dm365.c         | 1 +
 3 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index ddfdd82..29e08aa 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -1010,11 +1010,13 @@ static struct davinci_spi_platform_data da8xx_spi_pdata[] = {
 		.version	= SPI_VERSION_2,
 		.intr_line	= 1,
 		.dma_event_q	= EVENTQ_0,
+		.prescaler_limit = 2,
 	},
 	[1] = {
 		.version	= SPI_VERSION_2,
 		.intr_line	= 1,
 		.dma_event_q	= EVENTQ_0,
+		.prescaler_limit = 2,
 	},
 };
 
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 9cbeda7..567dc56 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -411,6 +411,7 @@ static struct davinci_spi_platform_data dm355_spi0_pdata = {
 	.num_chipselect = 2,
 	.cshold_bug	= true,
 	.dma_event_q	= EVENTQ_1,
+	.prescaler_limit = 1,
 };
 static struct platform_device dm355_spi0_device = {
 	.name = "spi_davinci",
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index e3a3c54..6a890a8 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -646,6 +646,7 @@ static struct davinci_spi_platform_data dm365_spi0_pdata = {
 	.version 	= SPI_VERSION_1,
 	.num_chipselect = 2,
 	.dma_event_q	= EVENTQ_3,
+	.prescaler_limit = 1,
 };
 
 static struct resource dm365_spi0_resources[] = {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1191758 — Re: [RESEND][PATCH 3/4] ARM: davinci: Set proper SPI prescale limit value

FromSekhar Nori <nsekhar@ti.com>
Date2015-07-24 14:00 +0200
SubjectRe: [RESEND][PATCH 3/4] ARM: davinci: Set proper SPI prescale limit value
Message-ID<pPJNU-4T4-3@gated-at.bofh.it>
In reply to#1189868
On Wednesday 22 July 2015 06:02 PM, Franklin S Cooper Jr wrote:
> SPI Davinci driver has been updated to allow SOCs to specify their minimum
> prescale value. Update the various SOCs board files that use this driver with
> their proper prescaler limit.
> 
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>

Acked-by: Sekhar Nori <nsekhar@ti.com>

in case Mark is okay to take it through his tree. It does not clash with
anything else I have for mach-davinci.

Thanks,
Sekhar

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1189869 — [RESEND][PATCH 2/4] spi: davinci: Choose correct pre-scaler limit based on SOC

FromFranklin S Cooper Jr <fcooper@ti.com>
Date2015-07-22 14:40 +0200
Subject[RESEND][PATCH 2/4] spi: davinci: Choose correct pre-scaler limit based on SOC
Message-ID<pP1tw-6UG-17@gated-at.bofh.it>
In reply to#1189864
Currently the pre-scaler limit is incorrect. The value differs slightly
for various devices so a single value can't be used. Using the compatible
field select the correct pre-scaler limit.

Add new compatible field value for Keystone devices to support their
unique pre-scaler limit value.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
 .../devicetree/bindings/spi/spi-davinci.txt        |  2 +
 drivers/spi/spi-davinci.c                          | 43 ++++++++++++++++++----
 include/linux/platform_data/spi-davinci.h          |  1 +
 3 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-davinci.txt b/Documentation/devicetree/bindings/spi/spi-davinci.txt
index 12ecfe9..d1e914a 100644
--- a/Documentation/devicetree/bindings/spi/spi-davinci.txt
+++ b/Documentation/devicetree/bindings/spi/spi-davinci.txt
@@ -12,6 +12,8 @@ Required properties:
 - compatible:
 	- "ti,dm6441-spi" for SPI used similar to that on DM644x SoC family
 	- "ti,da830-spi" for SPI used similar to that on DA8xx SoC family
+	- "ti,keystone-spi" for SPI used similar to that on Keystone2 SoC
+		family
 - reg: Offset and length of SPI controller register space
 - num-cs: Number of chip selects. This includes internal as well as
 	GPIO chip selects.
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index b4605c4..3cf9faa 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -139,6 +139,8 @@ struct davinci_spi {
 	u32			(*get_tx)(struct davinci_spi *);
 
 	u8			*bytes_per_word;
+
+	u8			prescaler_limit;
 };
 
 static struct davinci_spi_config davinci_spi_default_cfg;
@@ -266,7 +268,7 @@ static inline int davinci_spi_get_prescale(struct davinci_spi *dspi,
 	/* Subtract 1 to match what will be programmed into SPI register. */
 	ret = DIV_ROUND_UP(clk_get_rate(dspi->clk), max_speed_hz) - 1;
 
-	if (ret < 0 || ret > 255)
+	if (ret < dspi->prescaler_limit || ret > 255)
 		return -EINVAL;
 
 	return ret;
@@ -833,13 +835,40 @@ rx_dma_failed:
 }
 
 #if defined(CONFIG_OF)
+
+/* OF SPI data structure */
+struct davinci_spi_of_data {
+	u8	version;
+	u8	prescaler_limit;
+};
+
+static const struct davinci_spi_of_data dm6441_spi_data = {
+	.version = SPI_VERSION_1,
+	.prescaler_limit = 2,
+};
+
+static const struct davinci_spi_of_data da830_spi_data = {
+	.version = SPI_VERSION_2,
+	.prescaler_limit = 2,
+};
+
+static const struct davinci_spi_of_data keystone_spi_data = {
+	.version = SPI_VERSION_1,
+	.prescaler_limit = 0,
+};
+
 static const struct of_device_id davinci_spi_of_match[] = {
 	{
 		.compatible = "ti,dm6441-spi",
+		.data = &dm6441_spi_data,
 	},
 	{
 		.compatible = "ti,da830-spi",
-		.data = (void *)SPI_VERSION_2,
+		.data = &da830_spi_data,
+	},
+	{
+		.compatible = "ti,keystone-spi",
+		.data = &keystone_spi_data,
 	},
 	{ },
 };
@@ -858,21 +887,21 @@ static int spi_davinci_get_pdata(struct platform_device *pdev,
 			struct davinci_spi *dspi)
 {
 	struct device_node *node = pdev->dev.of_node;
+	struct davinci_spi_of_data *spi_data;
 	struct davinci_spi_platform_data *pdata;
 	unsigned int num_cs, intr_line = 0;
 	const struct of_device_id *match;
 
 	pdata = &dspi->pdata;
 
-	pdata->version = SPI_VERSION_1;
 	match = of_match_device(davinci_spi_of_match, &pdev->dev);
 	if (!match)
 		return -ENODEV;
 
-	/* match data has the SPI version number for SPI_VERSION_2 */
-	if (match->data == (void *)SPI_VERSION_2)
-		pdata->version = SPI_VERSION_2;
+	spi_data = (struct davinci_spi_of_data *)match->data;
 
+	pdata->version = spi_data->version;
+	pdata->prescaler_limit = spi_data->prescaler_limit;
 	/*
 	 * default num_cs is 1 and all chipsel are internal to the chip
 	 * indicated by chip_sel being NULL or cs_gpios being NULL or
@@ -992,7 +1021,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
 
 	dspi->bitbang.chipselect = davinci_spi_chipselect;
 	dspi->bitbang.setup_transfer = davinci_spi_setup_transfer;
-
+	dspi->prescaler_limit = pdata->prescaler_limit;
 	dspi->version = pdata->version;
 
 	dspi->bitbang.flags = SPI_NO_CS | SPI_LSB_FIRST | SPI_LOOP;
diff --git a/include/linux/platform_data/spi-davinci.h b/include/linux/platform_data/spi-davinci.h
index 8dc2fa47..f4edcb0 100644
--- a/include/linux/platform_data/spi-davinci.h
+++ b/include/linux/platform_data/spi-davinci.h
@@ -49,6 +49,7 @@ struct davinci_spi_platform_data {
 	u8			num_chipselect;
 	u8			intr_line;
 	u8			*chip_sel;
+	u8			prescaler_limit;
 	bool			cshold_bug;
 	enum dma_event_q	dma_event_q;
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1191764 — Re: [RESEND][PATCH 2/4] spi: davinci: Choose correct pre-scaler limit based on SOC

FromSekhar Nori <nsekhar@ti.com>
Date2015-07-24 14:00 +0200
SubjectRe: [RESEND][PATCH 2/4] spi: davinci: Choose correct pre-scaler limit based on SOC
Message-ID<pPJNV-4T4-21@gated-at.bofh.it>
In reply to#1189869
On Wednesday 22 July 2015 06:02 PM, Franklin S Cooper Jr wrote:
> Currently the pre-scaler limit is incorrect. The value differs slightly
> for various devices so a single value can't be used. Using the compatible
> field select the correct pre-scaler limit.
> 
> Add new compatible field value for Keystone devices to support their
> unique pre-scaler limit value.
> 
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>

Reviewed-by: Sekhar Nori <nsekhar@ti.com>

Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web