* [PATCH v2] i.MX: SPI: Respect SPI_LSB_FIRST flag in mode settings
2015-01-16 2:32 [PATCH 1/3] i.MX6: phytec: Separate SoM specific code Andrey Smirnov
@ 2015-01-16 2:32 ` Andrey Smirnov
2015-01-16 2:32 ` [PATCH 2/3] i.MX6: phytec: Check environment path selection for errors Andrey Smirnov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Smirnov @ 2015-01-16 2:32 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Add code to support SPI transfers that have data shifted out least
significant bit first. This is useful in many cases, but specifically
it is needed for drivers/firmware/altera_serial.c to work on i.MX
platform.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/spi/imx_spi.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 3146339..a1f19eb 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -137,6 +137,25 @@ static int imx_spi_setup(struct spi_device *spi)
return 0;
}
+static unsigned int imx_spi_maybe_reverse_bits(struct spi_device *spi, unsigned int word)
+{
+ unsigned int result = word;
+
+ if (spi->mode & SPI_LSB_FIRST) {
+ size_t bits_left = spi->bits_per_word - 1;
+
+ for (word >>= 1; word; word >>= 1) {
+ result <<= 1;
+ result |= word & 1;
+ bits_left--;
+ }
+
+ result <<= bits_left;
+ }
+
+ return result;
+}
+
static unsigned int cspi_0_0_xchg_single(struct imx_spi *imx, unsigned int data)
{
void __iomem *base = imx->regs;
@@ -382,9 +401,20 @@ static void cspi_2_3_chipselect(struct spi_device *spi, int is_active)
gpio_set_value(gpio, gpio_cs);
}
-static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
+static u32 imx_xchg_single(struct spi_device *spi, u32 tx_val)
{
+ u32 rx_val;
struct imx_spi *imx = container_of(spi->master, struct imx_spi, master);
+
+
+ tx_val = imx_spi_maybe_reverse_bits(spi, tx_val);
+ rx_val = imx->xchg_single(imx, tx_val);
+
+ return imx_spi_maybe_reverse_bits(spi, rx_val);
+}
+
+static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
+{
unsigned i;
if (spi->bits_per_word <= 8) {
@@ -393,7 +423,8 @@ static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
u8 rx_val;
for (i = 0; i < t->len; i++) {
- rx_val = imx->xchg_single(imx, tx_buf ? tx_buf[i] : 0);
+ rx_val = imx_xchg_single(spi, tx_buf ? tx_buf[i] : 0);
+
if (rx_buf)
rx_buf[i] = rx_val;
}
@@ -403,7 +434,8 @@ static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
u16 rx_val;
for (i = 0; i < t->len >> 1; i++) {
- rx_val = imx->xchg_single(imx, tx_buf ? tx_buf[i] : 0);
+ rx_val = imx_xchg_single(spi, tx_buf ? tx_buf[i] : 0);
+
if (rx_buf)
rx_buf[i] = rx_val;
}
@@ -413,7 +445,8 @@ static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
u32 rx_val;
for (i = 0; i < t->len >> 2; i++) {
- rx_val = imx->xchg_single(imx, tx_buf ? tx_buf[i] : 0);
+ rx_val = imx_xchg_single(spi, tx_buf ? tx_buf[i] : 0);
+
if (rx_buf)
rx_buf[i] = rx_val;
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] i.MX6: phytec: Check environment path selection for errors
2015-01-16 2:32 [PATCH 1/3] i.MX6: phytec: Separate SoM specific code Andrey Smirnov
2015-01-16 2:32 ` [PATCH v2] i.MX: SPI: Respect SPI_LSB_FIRST flag in mode settings Andrey Smirnov
@ 2015-01-16 2:32 ` Andrey Smirnov
2015-01-16 2:32 ` [PATCH 3/3] i.MX6: phytec: Allow multiple MMC devices to contain boot environment Andrey Smirnov
2015-01-16 7:12 ` [PATCH 1/3] i.MX6: phytec: Separate SoM specific code Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Smirnov @ 2015-01-16 2:32 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Add code to explicitly check for success of of_device_enable_path()
when selecting which media is expected to contain barebox environment.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
arch/arm/boards/phytec-phyflex-imx6/board.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boards/phytec-phyflex-imx6/board.c b/arch/arm/boards/phytec-phyflex-imx6/board.c
index 7ac7928..c731faf 100644
--- a/arch/arm/boards/phytec-phyflex-imx6/board.c
+++ b/arch/arm/boards/phytec-phyflex-imx6/board.c
@@ -65,6 +65,9 @@ static void phyflex_err006282_workaround(void)
static int phytec_pfla02_init(void)
{
+ int ret;
+ char *environment_path;
+
if (!of_machine_is_compatible("phytec,imx6q-pfla02") &&
!of_machine_is_compatible("phytec,imx6dl-pfla02") &&
!of_machine_is_compatible("phytec,imx6s-pfla02"))
@@ -76,17 +79,22 @@ static int phytec_pfla02_init(void)
switch (bootsource_get()) {
case BOOTSOURCE_MMC:
- of_device_enable_path("/chosen/environment-sd");
+ environment_path = "/chosen/environment-sd";
break;
case BOOTSOURCE_NAND:
- of_device_enable_path("/chosen/environment-nand");
+ environment_path = "/chosen/environment-nand";
break;
default:
case BOOTSOURCE_SPI:
- of_device_enable_path("/chosen/environment-spinor");
+ environment_path = "/chosen/environment-spinor";
break;
}
+ ret = of_device_enable_path(environment_path);
+ if (ret < 0)
+ pr_warn("Failed to enable environment partition '%s' (%d)\n",
+ environment_path, ret);
+
return 0;
}
device_initcall(phytec_pfla02_init);
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] i.MX6: phytec: Allow multiple MMC devices to contain boot environment
2015-01-16 2:32 [PATCH 1/3] i.MX6: phytec: Separate SoM specific code Andrey Smirnov
2015-01-16 2:32 ` [PATCH v2] i.MX: SPI: Respect SPI_LSB_FIRST flag in mode settings Andrey Smirnov
2015-01-16 2:32 ` [PATCH 2/3] i.MX6: phytec: Check environment path selection for errors Andrey Smirnov
@ 2015-01-16 2:32 ` Andrey Smirnov
2015-01-16 7:12 ` [PATCH 1/3] i.MX6: phytec: Separate SoM specific code Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Smirnov @ 2015-01-16 2:32 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Add code so that when booting from different SDHCI controllers barebox
would correctly set up where to look for bootloader environment.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
arch/arm/boards/phytec-phyflex-imx6/board.c | 10 +++++++---
arch/arm/dts/imx6qdl-phytec-pfla02.dtsi | 20 +++++++++++++++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boards/phytec-phyflex-imx6/board.c b/arch/arm/boards/phytec-phyflex-imx6/board.c
index c731faf..5f65261 100644
--- a/arch/arm/boards/phytec-phyflex-imx6/board.c
+++ b/arch/arm/boards/phytec-phyflex-imx6/board.c
@@ -17,6 +17,7 @@
*
*/
+#include <malloc.h>
#include <envfs.h>
#include <environment.h>
#include <bootsource.h>
@@ -79,14 +80,15 @@ static int phytec_pfla02_init(void)
switch (bootsource_get()) {
case BOOTSOURCE_MMC:
- environment_path = "/chosen/environment-sd";
+ environment_path = asprintf("/chosen/environment-sd%d",
+ bootsource_get_instance() + 1);
break;
case BOOTSOURCE_NAND:
- environment_path = "/chosen/environment-nand";
+ environment_path = asprintf("/chosen/environment-nand");
break;
default:
case BOOTSOURCE_SPI:
- environment_path = "/chosen/environment-spinor";
+ environment_path = asprintf("/chosen/environment-spinor");
break;
}
@@ -95,6 +97,8 @@ static int phytec_pfla02_init(void)
pr_warn("Failed to enable environment partition '%s' (%d)\n",
environment_path, ret);
+ free(environment_path);
+
return 0;
}
device_initcall(phytec_pfla02_init);
diff --git a/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi b/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi
index 32ce088..85cfec3 100644
--- a/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi
+++ b/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi
@@ -23,11 +23,29 @@
status = "disabled";
};
- environment-sd {
+ environment-sd1 {
+ compatible = "barebox,environment";
+ device-path = &usdhc1, "partname:barebox-environment";
+ status = "disabled";
+ };
+
+ environment-sd2 {
+ compatible = "barebox,environment";
+ device-path = &usdhc2, "partname:barebox-environment";
+ status = "disabled";
+ };
+
+ environment-sd3 {
compatible = "barebox,environment";
device-path = &usdhc3, "partname:barebox-environment";
status = "disabled";
};
+
+ environment-sd4 {
+ compatible = "barebox,environment";
+ device-path = &usdhc4, "partname:barebox-environment";
+ status = "disabled";
+ };
};
};
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] i.MX6: phytec: Separate SoM specific code
2015-01-16 2:32 [PATCH 1/3] i.MX6: phytec: Separate SoM specific code Andrey Smirnov
` (2 preceding siblings ...)
2015-01-16 2:32 ` [PATCH 3/3] i.MX6: phytec: Allow multiple MMC devices to contain boot environment Andrey Smirnov
@ 2015-01-16 7:12 ` Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2015-01-16 7:12 UTC (permalink / raw)
To: Andrey Smirnov; +Cc: barebox
On Thu, Jan 15, 2015 at 06:32:33PM -0800, Andrey Smirnov wrote:
> Separate SoM(designator PFLA02) specific and base board(designator
> PBAB0x) code into two distinct functions. PHYTEC default environment
> for PHYFLEX references peripherals that may or may not be used on
> custom baseboards used with SoMs. Move the code appending it into a
> separate function that would have effect only for boards explicitly
> claiming compatibility with PHYTEC baseboards.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> arch/arm/boards/phytec-phyflex-imx6/board.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
Applied all, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread