Re: [U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
Dear Jagan, Jagan Teki jagannadh.t...@gmail.com writes: Does this tested on hw, please re-base the tree and send the next version patch. Let me know if it ok to review under current tree. I'd appreciate a review of the latest patch [1,2]. There have been no changes in master to the files touched by the patch since I sent it. After rebasing the entire series on today's master (d6639d1) I've successfully verified SPI flash functionality on CuBox Pro. Sascha [1] mid:1369593423-19763-6-git-send-email-t-ub...@infra-silbe.de [2] http://patchwork.ozlabs.org/patch/246468/ pgpWOycwgx9zs.pgp Description: PGP signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
On Mon, Jun 3, 2013 at 11:01 PM, Sascha Silbe t-ub...@infra-silbe.de wrote: Dear Jagan, Jagan Teki jagannadh.t...@gmail.com writes: Does this tested on hw, please re-base the tree and send the next version patch. Let me know if it ok to review under current tree. I'd appreciate a review of the latest patch [1,2]. There have been no changes in master to the files touched by the patch since I sent it. After rebasing the entire series on today's master (d6639d1) I've successfully verified SPI flash functionality on CuBox Pro. Sascha [1] mid:1369593423-19763-6-git-send-email-t-ub...@infra-silbe.de [2] http://patchwork.ozlabs.org/patch/246468/ Thank you, means this v4 is the latest one? http://patchwork.ozlabs.org/patch/246468/ -- Thanks, Jagan. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
Dear Jagan, Jagan Teki jagannadh.t...@gmail.com writes: I'd appreciate a review of the latest patch [1,2]. [...] [1] mid:1369593423-19763-6-git-send-email-t-ub...@infra-silbe.de [2] http://patchwork.ozlabs.org/patch/246468/ Thank you, means this v4 is the latest one? http://patchwork.ozlabs.org/patch/246468/ Yes, it is. Sascha pgpgMrapTfTCb.pgp Description: PGP signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
On 06/03/2013 07:31 PM, Sascha Silbe wrote: From: Sebastian Hesselbarth sebastian.hesselba...@gmail.com This adds an SPI driver for Marvell Dove SoCs. This driver is taken from kirkwood_spi but removes mpp configuration as dove has dedicated spi pins. As a future clean-up step, the code for orion5x, kirkwood and dove could be merged, with MPP configuration being be handled as part of cpu/board-specific setup. Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com Signed-off-by: Sascha Silbe t-ub...@infra-silbe.de --- v3-v4: renamed to dove, adjusted description, removed unused variable, made checkpatch clean Sascha, renaming it to dove_spi to obfuscate it is actually a copy of kirkwood_spi that will also work for orion5x and mv78x00 does _not_ match my intention when I posted this driver. Feel free to pick up the patches but it should remain generic for all Orion SoCs. kirkwood_spi has mpp stuff inside that is totally wrong there, move it to board setup and just rename kirkwood_spi to something more generic. Sebastian ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
Hi, Does this tested on hw, please re-base the tree and send the next version patch. Let me know if it ok to review under current tree. -- Thanks, Jagan. On Mon, Feb 11, 2013 at 9:09 AM, Prafulla Wadaskar prafu...@marvell.com wrote: -Original Message- From: Sebastian Hesselbarth [mailto:sebastian.hesselba...@gmail.com] Sent: 17 January 2013 00:55 To: Sebastian Hesselbarth Cc: u-boot@lists.denx.de; Rabeeh Khoury; Albert Aribaud; Prafulla Wadaskar; Andy Fleming; Joe Hershberger; Daniel Stodden; Luka Perkov Subject: [PATCH v3 04/10] SPI: Add Orion SPI driver This adds an SPI driver found on Marvell Orion SoCs. This driver is taken from kirkwood_spi but removes mpp configuration as dove has dedicated spi pins. To have a common driver for orion5x, kirkwood, and dove, mpp configuration should be handled in some cpu/board- specific the proposal of having common driver will be greatly appreciated. Pls go ahead and do it if possible for you I think adding orion_spi.c to enable dove support doesn't sound good. Regards... Prafulla . . . ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
-Original Message- From: Sebastian Hesselbarth [mailto:sebastian.hesselba...@gmail.com] Sent: 17 January 2013 00:55 To: Sebastian Hesselbarth Cc: u-boot@lists.denx.de; Rabeeh Khoury; Albert Aribaud; Prafulla Wadaskar; Andy Fleming; Joe Hershberger; Daniel Stodden; Luka Perkov Subject: [PATCH v3 04/10] SPI: Add Orion SPI driver This adds an SPI driver found on Marvell Orion SoCs. This driver is taken from kirkwood_spi but removes mpp configuration as dove has dedicated spi pins. To have a common driver for orion5x, kirkwood, and dove, mpp configuration should be handled in some cpu/board- specific the proposal of having common driver will be greatly appreciated. Pls go ahead and do it if possible for you I think adding orion_spi.c to enable dove support doesn't sound good. Regards... Prafulla . . . ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 04/10] SPI: Add Orion SPI driver
This adds an SPI driver found on Marvell Orion SoCs. This driver is taken from kirkwood_spi but removes mpp configuration as dove has dedicated spi pins. To have a common driver for orion5x, kirkwood, and dove, mpp configuration should be handled in some cpu/board-specific setup. Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com --- Cc: u-boot@lists.denx.de Cc: Sebastian Hesselbarth sebastian.hesselba...@gmail.com Cc: Rabeeh Khoury rab...@solid-run.com Cc: Albert Aribaud albert.u.b...@aribaud.net Cc: Prafulla Wadaskar prafu...@marvell.com Cc: Andy Fleming aflem...@gmail.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Daniel Stodden daniel.stod...@gmail.com Cc: Luka Perkov l...@openwrt.org --- drivers/spi/Makefile|1 + drivers/spi/orion_spi.c | 217 +++ 2 files changed, 218 insertions(+) create mode 100644 drivers/spi/orion_spi.c diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 824d357..624bb72 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -35,6 +35,7 @@ COBJS-$(CONFIG_CF_SPI) += cf_spi.o COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o +COBJS-$(CONFIG_ORION_SPI) += orion_spi.o COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o diff --git a/drivers/spi/orion_spi.c b/drivers/spi/orion_spi.c new file mode 100644 index 000..8a50531 --- /dev/null +++ b/drivers/spi/orion_spi.c @@ -0,0 +1,217 @@ +/* + * Marvell Orion SoCs common spi driver + * + * Sebastian Hesselbarth sebastian.hesselba...@gmail.com + * based on kirkwood_spi.c written by + * Prafulla Wadaskar prafu...@marvell.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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 option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include common.h +#include malloc.h +#include spi.h +#include asm/io.h +#include asm/arch/config.h + +/* SPI Registers on orion SOC */ +struct orionspi_registers { + u32 ctrl; /* 0x00 */ + u32 cfg;/* 0x04 */ + u32 dout; /* 0x08 */ + u32 din;/* 0x0c */ + u32 irq_cause; /* 0x10 */ + u32 irq_mask; /* 0x14 */ +}; + +#define ORIONSPI_CLKPRESCL_MASK0x1f +#define ORIONSPI_CLKPRESCL_MIN 0x12 +#define ORIONSPI_CSN_ACT 1 /* Activates serial memory interface */ +#define ORIONSPI_SMEMRDY (1 1) /* SerMem Data xfer ready */ +#define ORIONSPI_IRQUNMASK 1 /* unmask SPI interrupt */ +#define ORIONSPI_IRQMASK 0 /* mask SPI interrupt */ +#define ORIONSPI_SMEMRDIRQ 1 /* SerMem data xfer ready irq */ +#define ORIONSPI_XFERLEN_1BYTE 0 +#define ORIONSPI_XFERLEN_2BYTE (1 5) +#define ORIONSPI_XFERLEN_MASK (1 5) +#define ORIONSPI_ADRLEN_1BYTE 0 +#define ORIONSPI_ADRLEN_2BYTE (1 8) +#define ORIONSPI_ADRLEN_3BYTE (2 8) +#define ORIONSPI_ADRLEN_4BYTE (3 8) +#define ORIONSPI_ADRLEN_MASK (3 8) +#define ORIONSPI_TIMEOUT 1 + +static struct orionspi_registers *spireg = + (struct orionspi_registers *)ORION_SPI_BASE; + +struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, + unsigned int max_hz, unsigned int mode) +{ + struct spi_slave *slave; + u32 data; + u32 kwspi_mpp_config[] = { 0, 0 }; + + if (!spi_cs_is_valid(bus, cs)) + return NULL; + + slave = malloc(sizeof(struct spi_slave)); + if (!slave) + return NULL; + + slave-bus = bus; + slave-cs = cs; + + writel(~ORIONSPI_CSN_ACT | ORIONSPI_SMEMRDY, spireg-ctrl); + + /* calculate spi clock prescaller using max_hz */ + data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10; + data = data ORIONSPI_CLKPRESCL_MIN ? ORIONSPI_CLKPRESCL_MIN : data; + data = data ORIONSPI_CLKPRESCL_MASK ? ORIONSPI_CLKPRESCL_MASK : data; + + /* program spi clock prescaller using max_hz */ + writel(ORIONSPI_ADRLEN_3BYTE | data, spireg-cfg); + debug(data = 0x%08x\n, data); + + writel(ORIONSPI_SMEMRDIRQ, spireg-irq_cause); + writel(ORIONSPI_IRQMASK, spireg-irq_mask); + + return slave; +} + +void spi_free_slave(struct spi_slave *slave) +{ +