From: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
To: Cyrille Pitchen
<cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
<broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
<pawel.moll-5wv7dgnIgG8@public.gmane.org>,
<mark.rutland-5wv7dgnIgG8@public.gmane.org>,
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
<galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Subject: Re: [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller
Date: Tue, 9 Jun 2015 14:15:09 +0200 [thread overview]
Message-ID: <5576D8CD.2090608@atmel.com> (raw)
In-Reply-To: <c05f4d9abfdabb62b3b3cfeb57a3f9c138b4e45d.1433850255.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Le 09/06/2015 13:53, Cyrille Pitchen a écrit :
> This patch relies on the CSAAT (Chip Select Active After Transfer) feature
> introduced by the version 2 of the spi controller. This new mode allows to
> use properly the internal chip-select output pin of the spi controller
> instead of using external gpios. Consequently, the "cs-gpios" device-tree
> property becomes optional.
>
> When the new CSAAT bit is set into the Chip Select Register, the internal
> chip-select output pin remains asserted till both the following conditions
> become true:
> - the LASTXFER bit is set into the Control Register (or the Transmit Data
> Register)
> - the Transmit Data Register and its shift register are empty.
>
> WARNING: if the LASTXFER bit is set into the Control Register then new
> data are written into the Transmit Data Register fast enough to keep its
> shifter not empty, the chip-select output pin remains asserted. Only when
> the shifter becomes empty, the chip-select output pin is unasserted.
>
> When the CSAAT bit is clear in the Chip Select Register, the LASTXFER bit
> is ignored in both the Control Register and the Transmit Data Register.
> The internal chip-select output pin remains active as long as the Transmit
> Data Register or its shift register are not empty.
>
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> ---
> drivers/spi/spi-atmel.c | 37 ++++++++++++++++++++++++++++---------
> 1 file changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index a2f40b1..aa7d202 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -246,6 +246,7 @@ struct atmel_spi {
>
> bool use_dma;
> bool use_pdc;
> + bool use_cs_gpios;
> /* dmaengine data */
> struct atmel_spi_dma dma;
>
> @@ -321,7 +322,8 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
> }
>
> mr = spi_readl(as, MR);
> - gpio_set_value(asd->npcs_pin, active);
> + if (as->use_cs_gpios)
> + gpio_set_value(asd->npcs_pin, active);
> } else {
> u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
> int i;
> @@ -337,7 +339,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
>
> mr = spi_readl(as, MR);
> mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr);
> - if (spi->chip_select != 0)
> + if (as->use_cs_gpios && spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, active);
> spi_writel(as, MR, mr);
> }
> @@ -366,7 +368,9 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
> asd->npcs_pin, active ? " (low)" : "",
> mr);
>
> - if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> + if (!as->use_cs_gpios)
> + spi_writel(as, CR, SPI_BIT(LASTXFER));
> + else if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, !active);
> }
>
> @@ -996,6 +1000,8 @@ static int atmel_spi_setup(struct spi_device *spi)
> csr |= SPI_BIT(CPOL);
> if (!(spi->mode & SPI_CPHA))
> csr |= SPI_BIT(NCPHA);
> + if (!as->use_cs_gpios)
> + csr |= SPI_BIT(CSAAT);
>
> /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs.
> *
> @@ -1009,7 +1015,9 @@ static int atmel_spi_setup(struct spi_device *spi)
> /* chipselect must have been muxed as GPIO (e.g. in board setup) */
> npcs_pin = (unsigned long)spi->controller_data;
>
> - if (gpio_is_valid(spi->cs_gpio))
> + if (!as->use_cs_gpios)
> + npcs_pin = spi->chip_select;
> + else if (gpio_is_valid(spi->cs_gpio))
> npcs_pin = spi->cs_gpio;
>
> asd = spi->controller_state;
> @@ -1018,15 +1026,19 @@ static int atmel_spi_setup(struct spi_device *spi)
> if (!asd)
> return -ENOMEM;
>
> - ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> - if (ret) {
> - kfree(asd);
> - return ret;
> + if (as->use_cs_gpios) {
> + ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> + if (ret) {
> + kfree(asd);
> + return ret;
> + }
> +
> + gpio_direction_output(npcs_pin,
> + !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->npcs_pin = npcs_pin;
> spi->controller_state = asd;
> - gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->csr = csr;
> @@ -1338,6 +1350,13 @@ static int atmel_spi_probe(struct platform_device *pdev)
>
> atmel_get_caps(as);
>
> + as->use_cs_gpios = true;
> + if (atmel_spi_is_v2(as) &&
> + !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) {
> + as->use_cs_gpios = false;
> + master->num_chipselect = 4;
> + }
> +
> as->use_dma = false;
> as->use_pdc = false;
> if (as->caps.has_dma_support) {
>
--
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller
Date: Tue, 9 Jun 2015 14:15:09 +0200 [thread overview]
Message-ID: <5576D8CD.2090608@atmel.com> (raw)
In-Reply-To: <c05f4d9abfdabb62b3b3cfeb57a3f9c138b4e45d.1433850255.git.cyrille.pitchen@atmel.com>
Le 09/06/2015 13:53, Cyrille Pitchen a ?crit :
> This patch relies on the CSAAT (Chip Select Active After Transfer) feature
> introduced by the version 2 of the spi controller. This new mode allows to
> use properly the internal chip-select output pin of the spi controller
> instead of using external gpios. Consequently, the "cs-gpios" device-tree
> property becomes optional.
>
> When the new CSAAT bit is set into the Chip Select Register, the internal
> chip-select output pin remains asserted till both the following conditions
> become true:
> - the LASTXFER bit is set into the Control Register (or the Transmit Data
> Register)
> - the Transmit Data Register and its shift register are empty.
>
> WARNING: if the LASTXFER bit is set into the Control Register then new
> data are written into the Transmit Data Register fast enough to keep its
> shifter not empty, the chip-select output pin remains asserted. Only when
> the shifter becomes empty, the chip-select output pin is unasserted.
>
> When the CSAAT bit is clear in the Chip Select Register, the LASTXFER bit
> is ignored in both the Control Register and the Transmit Data Register.
> The internal chip-select output pin remains active as long as the Transmit
> Data Register or its shift register are not empty.
>
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/spi/spi-atmel.c | 37 ++++++++++++++++++++++++++++---------
> 1 file changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index a2f40b1..aa7d202 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -246,6 +246,7 @@ struct atmel_spi {
>
> bool use_dma;
> bool use_pdc;
> + bool use_cs_gpios;
> /* dmaengine data */
> struct atmel_spi_dma dma;
>
> @@ -321,7 +322,8 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
> }
>
> mr = spi_readl(as, MR);
> - gpio_set_value(asd->npcs_pin, active);
> + if (as->use_cs_gpios)
> + gpio_set_value(asd->npcs_pin, active);
> } else {
> u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
> int i;
> @@ -337,7 +339,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
>
> mr = spi_readl(as, MR);
> mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr);
> - if (spi->chip_select != 0)
> + if (as->use_cs_gpios && spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, active);
> spi_writel(as, MR, mr);
> }
> @@ -366,7 +368,9 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
> asd->npcs_pin, active ? " (low)" : "",
> mr);
>
> - if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> + if (!as->use_cs_gpios)
> + spi_writel(as, CR, SPI_BIT(LASTXFER));
> + else if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, !active);
> }
>
> @@ -996,6 +1000,8 @@ static int atmel_spi_setup(struct spi_device *spi)
> csr |= SPI_BIT(CPOL);
> if (!(spi->mode & SPI_CPHA))
> csr |= SPI_BIT(NCPHA);
> + if (!as->use_cs_gpios)
> + csr |= SPI_BIT(CSAAT);
>
> /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs.
> *
> @@ -1009,7 +1015,9 @@ static int atmel_spi_setup(struct spi_device *spi)
> /* chipselect must have been muxed as GPIO (e.g. in board setup) */
> npcs_pin = (unsigned long)spi->controller_data;
>
> - if (gpio_is_valid(spi->cs_gpio))
> + if (!as->use_cs_gpios)
> + npcs_pin = spi->chip_select;
> + else if (gpio_is_valid(spi->cs_gpio))
> npcs_pin = spi->cs_gpio;
>
> asd = spi->controller_state;
> @@ -1018,15 +1026,19 @@ static int atmel_spi_setup(struct spi_device *spi)
> if (!asd)
> return -ENOMEM;
>
> - ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> - if (ret) {
> - kfree(asd);
> - return ret;
> + if (as->use_cs_gpios) {
> + ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> + if (ret) {
> + kfree(asd);
> + return ret;
> + }
> +
> + gpio_direction_output(npcs_pin,
> + !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->npcs_pin = npcs_pin;
> spi->controller_state = asd;
> - gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->csr = csr;
> @@ -1338,6 +1350,13 @@ static int atmel_spi_probe(struct platform_device *pdev)
>
> atmel_get_caps(as);
>
> + as->use_cs_gpios = true;
> + if (atmel_spi_is_v2(as) &&
> + !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) {
> + as->use_cs_gpios = false;
> + master->num_chipselect = 4;
> + }
> +
> as->use_dma = false;
> as->use_pdc = false;
> if (as->caps.has_dma_support) {
>
--
Nicolas Ferre
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
To: Cyrille Pitchen
<cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
pawel.moll-5wv7dgnIgG8@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Subject: Re: [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller
Date: Tue, 9 Jun 2015 14:15:09 +0200 [thread overview]
Message-ID: <5576D8CD.2090608@atmel.com> (raw)
In-Reply-To: <c05f4d9abfdabb62b3b3cfeb57a3f9c138b4e45d.1433850255.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Le 09/06/2015 13:53, Cyrille Pitchen a écrit :
> This patch relies on the CSAAT (Chip Select Active After Transfer) feature
> introduced by the version 2 of the spi controller. This new mode allows to
> use properly the internal chip-select output pin of the spi controller
> instead of using external gpios. Consequently, the "cs-gpios" device-tree
> property becomes optional.
>
> When the new CSAAT bit is set into the Chip Select Register, the internal
> chip-select output pin remains asserted till both the following conditions
> become true:
> - the LASTXFER bit is set into the Control Register (or the Transmit Data
> Register)
> - the Transmit Data Register and its shift register are empty.
>
> WARNING: if the LASTXFER bit is set into the Control Register then new
> data are written into the Transmit Data Register fast enough to keep its
> shifter not empty, the chip-select output pin remains asserted. Only when
> the shifter becomes empty, the chip-select output pin is unasserted.
>
> When the CSAAT bit is clear in the Chip Select Register, the LASTXFER bit
> is ignored in both the Control Register and the Transmit Data Register.
> The internal chip-select output pin remains active as long as the Transmit
> Data Register or its shift register are not empty.
>
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> ---
> drivers/spi/spi-atmel.c | 37 ++++++++++++++++++++++++++++---------
> 1 file changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index a2f40b1..aa7d202 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -246,6 +246,7 @@ struct atmel_spi {
>
> bool use_dma;
> bool use_pdc;
> + bool use_cs_gpios;
> /* dmaengine data */
> struct atmel_spi_dma dma;
>
> @@ -321,7 +322,8 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
> }
>
> mr = spi_readl(as, MR);
> - gpio_set_value(asd->npcs_pin, active);
> + if (as->use_cs_gpios)
> + gpio_set_value(asd->npcs_pin, active);
> } else {
> u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
> int i;
> @@ -337,7 +339,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
>
> mr = spi_readl(as, MR);
> mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr);
> - if (spi->chip_select != 0)
> + if (as->use_cs_gpios && spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, active);
> spi_writel(as, MR, mr);
> }
> @@ -366,7 +368,9 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
> asd->npcs_pin, active ? " (low)" : "",
> mr);
>
> - if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> + if (!as->use_cs_gpios)
> + spi_writel(as, CR, SPI_BIT(LASTXFER));
> + else if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, !active);
> }
>
> @@ -996,6 +1000,8 @@ static int atmel_spi_setup(struct spi_device *spi)
> csr |= SPI_BIT(CPOL);
> if (!(spi->mode & SPI_CPHA))
> csr |= SPI_BIT(NCPHA);
> + if (!as->use_cs_gpios)
> + csr |= SPI_BIT(CSAAT);
>
> /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs.
> *
> @@ -1009,7 +1015,9 @@ static int atmel_spi_setup(struct spi_device *spi)
> /* chipselect must have been muxed as GPIO (e.g. in board setup) */
> npcs_pin = (unsigned long)spi->controller_data;
>
> - if (gpio_is_valid(spi->cs_gpio))
> + if (!as->use_cs_gpios)
> + npcs_pin = spi->chip_select;
> + else if (gpio_is_valid(spi->cs_gpio))
> npcs_pin = spi->cs_gpio;
>
> asd = spi->controller_state;
> @@ -1018,15 +1026,19 @@ static int atmel_spi_setup(struct spi_device *spi)
> if (!asd)
> return -ENOMEM;
>
> - ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> - if (ret) {
> - kfree(asd);
> - return ret;
> + if (as->use_cs_gpios) {
> + ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> + if (ret) {
> + kfree(asd);
> + return ret;
> + }
> +
> + gpio_direction_output(npcs_pin,
> + !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->npcs_pin = npcs_pin;
> spi->controller_state = asd;
> - gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->csr = csr;
> @@ -1338,6 +1350,13 @@ static int atmel_spi_probe(struct platform_device *pdev)
>
> atmel_get_caps(as);
>
> + as->use_cs_gpios = true;
> + if (atmel_spi_is_v2(as) &&
> + !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) {
> + as->use_cs_gpios = false;
> + master->num_chipselect = 4;
> + }
> +
> as->use_dma = false;
> as->use_pdc = false;
> if (as->caps.has_dma_support) {
>
--
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Cyrille Pitchen <cyrille.pitchen@atmel.com>, <broonie@kernel.org>,
<linux-spi@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <robh+dt@kernel.org>,
<pawel.moll@arm.com>, <mark.rutland@arm.com>,
<ijc+devicetree@hellion.org.uk>, <galak@codeaurora.org>
Subject: Re: [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller
Date: Tue, 9 Jun 2015 14:15:09 +0200 [thread overview]
Message-ID: <5576D8CD.2090608@atmel.com> (raw)
In-Reply-To: <c05f4d9abfdabb62b3b3cfeb57a3f9c138b4e45d.1433850255.git.cyrille.pitchen@atmel.com>
Le 09/06/2015 13:53, Cyrille Pitchen a écrit :
> This patch relies on the CSAAT (Chip Select Active After Transfer) feature
> introduced by the version 2 of the spi controller. This new mode allows to
> use properly the internal chip-select output pin of the spi controller
> instead of using external gpios. Consequently, the "cs-gpios" device-tree
> property becomes optional.
>
> When the new CSAAT bit is set into the Chip Select Register, the internal
> chip-select output pin remains asserted till both the following conditions
> become true:
> - the LASTXFER bit is set into the Control Register (or the Transmit Data
> Register)
> - the Transmit Data Register and its shift register are empty.
>
> WARNING: if the LASTXFER bit is set into the Control Register then new
> data are written into the Transmit Data Register fast enough to keep its
> shifter not empty, the chip-select output pin remains asserted. Only when
> the shifter becomes empty, the chip-select output pin is unasserted.
>
> When the CSAAT bit is clear in the Chip Select Register, the LASTXFER bit
> is ignored in both the Control Register and the Transmit Data Register.
> The internal chip-select output pin remains active as long as the Transmit
> Data Register or its shift register are not empty.
>
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/spi/spi-atmel.c | 37 ++++++++++++++++++++++++++++---------
> 1 file changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index a2f40b1..aa7d202 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -246,6 +246,7 @@ struct atmel_spi {
>
> bool use_dma;
> bool use_pdc;
> + bool use_cs_gpios;
> /* dmaengine data */
> struct atmel_spi_dma dma;
>
> @@ -321,7 +322,8 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
> }
>
> mr = spi_readl(as, MR);
> - gpio_set_value(asd->npcs_pin, active);
> + if (as->use_cs_gpios)
> + gpio_set_value(asd->npcs_pin, active);
> } else {
> u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
> int i;
> @@ -337,7 +339,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
>
> mr = spi_readl(as, MR);
> mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr);
> - if (spi->chip_select != 0)
> + if (as->use_cs_gpios && spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, active);
> spi_writel(as, MR, mr);
> }
> @@ -366,7 +368,9 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
> asd->npcs_pin, active ? " (low)" : "",
> mr);
>
> - if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> + if (!as->use_cs_gpios)
> + spi_writel(as, CR, SPI_BIT(LASTXFER));
> + else if (atmel_spi_is_v2(as) || spi->chip_select != 0)
> gpio_set_value(asd->npcs_pin, !active);
> }
>
> @@ -996,6 +1000,8 @@ static int atmel_spi_setup(struct spi_device *spi)
> csr |= SPI_BIT(CPOL);
> if (!(spi->mode & SPI_CPHA))
> csr |= SPI_BIT(NCPHA);
> + if (!as->use_cs_gpios)
> + csr |= SPI_BIT(CSAAT);
>
> /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs.
> *
> @@ -1009,7 +1015,9 @@ static int atmel_spi_setup(struct spi_device *spi)
> /* chipselect must have been muxed as GPIO (e.g. in board setup) */
> npcs_pin = (unsigned long)spi->controller_data;
>
> - if (gpio_is_valid(spi->cs_gpio))
> + if (!as->use_cs_gpios)
> + npcs_pin = spi->chip_select;
> + else if (gpio_is_valid(spi->cs_gpio))
> npcs_pin = spi->cs_gpio;
>
> asd = spi->controller_state;
> @@ -1018,15 +1026,19 @@ static int atmel_spi_setup(struct spi_device *spi)
> if (!asd)
> return -ENOMEM;
>
> - ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> - if (ret) {
> - kfree(asd);
> - return ret;
> + if (as->use_cs_gpios) {
> + ret = gpio_request(npcs_pin, dev_name(&spi->dev));
> + if (ret) {
> + kfree(asd);
> + return ret;
> + }
> +
> + gpio_direction_output(npcs_pin,
> + !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->npcs_pin = npcs_pin;
> spi->controller_state = asd;
> - gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH));
> }
>
> asd->csr = csr;
> @@ -1338,6 +1350,13 @@ static int atmel_spi_probe(struct platform_device *pdev)
>
> atmel_get_caps(as);
>
> + as->use_cs_gpios = true;
> + if (atmel_spi_is_v2(as) &&
> + !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) {
> + as->use_cs_gpios = false;
> + master->num_chipselect = 4;
> + }
> +
> as->use_dma = false;
> as->use_pdc = false;
> if (as->caps.has_dma_support) {
>
--
Nicolas Ferre
next prev parent reply other threads:[~2015-06-09 12:15 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 11:53 [PATCH v3 0/3] spi: atmel: add support to FIFOs and the internal chip-select Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` [PATCH v3 2/3] spi: atmel: update DT bindings documentation Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
[not found] ` <ce7c16faafaa24f5bb711115c0eea1f8992d08c3.1433850255.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 17:25 ` Mark Brown
2015-06-09 17:25 ` Mark Brown
2015-06-09 17:25 ` Mark Brown
[not found] ` <20150609172531.GM14071-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-06-11 16:37 ` Cyrille Pitchen
2015-06-11 16:37 ` Cyrille Pitchen
2015-06-11 16:37 ` Cyrille Pitchen
2015-06-11 16:37 ` Cyrille Pitchen
[not found] ` <5579B95F.9060307-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2015-06-15 15:49 ` Mark Brown
2015-06-15 15:49 ` Mark Brown
2015-06-15 15:49 ` Mark Brown
[not found] ` <cover.1433850255.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2015-06-09 11:53 ` [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
[not found] ` <c05f4d9abfdabb62b3b3cfeb57a3f9c138b4e45d.1433850255.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2015-06-09 12:15 ` Nicolas Ferre [this message]
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 12:15 ` Nicolas Ferre
2015-06-09 17:26 ` Mark Brown
2015-06-09 17:26 ` Mark Brown
2015-06-09 17:26 ` Mark Brown
2016-01-05 21:50 ` Måns Rullgård
2016-01-05 21:50 ` Måns Rullgård
2016-01-05 21:50 ` Måns Rullgård
2016-01-07 15:40 ` Mark Brown
2016-01-07 15:40 ` Mark Brown
[not found] ` <20160107154024.GF6588-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-01-07 16:14 ` Måns Rullgård
2016-01-07 16:14 ` Måns Rullgård
2016-01-07 16:14 ` Måns Rullgård
[not found] ` <yw1xvb771yrl.fsf-OEaqT8BN2ezZK2NkWkPsZwC/G2K4zDHf@public.gmane.org>
2016-01-27 15:46 ` Nicolas Ferre
2016-01-27 15:46 ` Nicolas Ferre
2016-01-27 15:46 ` Nicolas Ferre
2016-01-27 15:46 ` Nicolas Ferre
[not found] ` <56A8E66B.208-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-01-27 15:53 ` Måns Rullgård
2016-01-27 15:53 ` Måns Rullgård
2016-01-27 15:53 ` Måns Rullgård
2016-01-27 15:53 ` Måns Rullgård
[not found] ` <yw1xk2mvj9xp.fsf-OEaqT8BN2ezZK2NkWkPsZwC/G2K4zDHf@public.gmane.org>
2016-01-27 16:55 ` Nicolas Ferre
2016-01-27 16:55 ` Nicolas Ferre
2016-01-27 16:55 ` Nicolas Ferre
2016-01-27 16:55 ` Nicolas Ferre
[not found] ` <56A8F66E.6070105-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-01-27 16:57 ` Måns Rullgård
2016-01-27 16:57 ` Måns Rullgård
2016-01-27 16:57 ` Måns Rullgård
2016-01-27 16:57 ` Måns Rullgård
2015-06-09 11:53 ` [PATCH v3 3/3] spi: atmel: add support to FIFOs Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 11:53 ` Cyrille Pitchen
2015-06-09 12:24 ` Nicolas Ferre
2015-06-09 12:24 ` Nicolas Ferre
2015-06-09 12:24 ` Nicolas Ferre
[not found] ` <bb9ae6c3a3567d4fae7689a31f771da6036661bd.1433850255.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2015-06-09 17:30 ` Mark Brown
2015-06-09 17:30 ` Mark Brown
2015-06-09 17:30 ` 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=5576D8CD.2090608@atmel.com \
--to=nicolas.ferre-aife0yeh4naavxtiumwx3w@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.