Re: [U-Boot] [PATCH v3] dm: spi: Convert Freescale DSPI driver to driver model

2015-03-31 Thread Simon Glass
On 31 March 2015 at 19:55, Simon Glass s...@chromium.org wrote:
 On 24 March 2015 at 08:03, Haikun Wang haikun.w...@freescale.com wrote:
 Move the Freescale DSPI driver over to driver model.

 Signed-off-by: Haikun Wang haikun.w...@freescale.com
 ---

 Changes in v3:
 - Coding style cleanup
 - Remove cur_slave_plat in structure fsl_dspi_priv
 - Change arguments of 'claim_bus' and 'release_bus'
 - Remove 'fsl_dspi_child_post_remove'
 - Add support NO-DM SPI
 - Add 'cpu_dspi_xxx' platform speical configure interface

 Changes in v2:
 - Coding style cleanup
 - Add some comments
 - Use structures for I/O access
 - Handle timeout case in 'dspi_tx' and 'dspi_rx'
 - Move some register configurations from 'set_mode' to 'claim_bus'
 - Rename structure fsl_dspi_platdata's member baudrate
 - Remove some redundancy code

 Changes in v1: None

  drivers/spi/Makefile   |   1 +
  drivers/spi/fsl_dspi.c | 737 
 +
  include/fsl_dspi.h | 150 ++
  3 files changed, 888 insertions(+)
  create mode 100644 drivers/spi/fsl_dspi.c
  create mode 100644 include/fsl_dspi.h

 Acked-by: Simon Glass s...@chromium.org

Applied to u-boot-dm/next, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3] dm: spi: Convert Freescale DSPI driver to driver model

2015-03-31 Thread Simon Glass
On 24 March 2015 at 08:03, Haikun Wang haikun.w...@freescale.com wrote:
 Move the Freescale DSPI driver over to driver model.

 Signed-off-by: Haikun Wang haikun.w...@freescale.com
 ---

 Changes in v3:
 - Coding style cleanup
 - Remove cur_slave_plat in structure fsl_dspi_priv
 - Change arguments of 'claim_bus' and 'release_bus'
 - Remove 'fsl_dspi_child_post_remove'
 - Add support NO-DM SPI
 - Add 'cpu_dspi_xxx' platform speical configure interface

 Changes in v2:
 - Coding style cleanup
 - Add some comments
 - Use structures for I/O access
 - Handle timeout case in 'dspi_tx' and 'dspi_rx'
 - Move some register configurations from 'set_mode' to 'claim_bus'
 - Rename structure fsl_dspi_platdata's member baudrate
 - Remove some redundancy code

 Changes in v1: None

  drivers/spi/Makefile   |   1 +
  drivers/spi/fsl_dspi.c | 737 
 +
  include/fsl_dspi.h | 150 ++
  3 files changed, 888 insertions(+)
  create mode 100644 drivers/spi/fsl_dspi.c
  create mode 100644 include/fsl_dspi.h

Acked-by: Simon Glass s...@chromium.org
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] dm: spi: Convert Freescale DSPI driver to driver model

2015-03-24 Thread Haikun Wang
Move the Freescale DSPI driver over to driver model.

Signed-off-by: Haikun Wang haikun.w...@freescale.com
---

Changes in v3:
- Coding style cleanup
- Remove cur_slave_plat in structure fsl_dspi_priv
- Change arguments of 'claim_bus' and 'release_bus'
- Remove 'fsl_dspi_child_post_remove'
- Add support NO-DM SPI
- Add 'cpu_dspi_xxx' platform speical configure interface

Changes in v2:
- Coding style cleanup
- Add some comments
- Use structures for I/O access
- Handle timeout case in 'dspi_tx' and 'dspi_rx'
- Move some register configurations from 'set_mode' to 'claim_bus'
- Rename structure fsl_dspi_platdata's member baudrate 
- Remove some redundancy code

Changes in v1: None

 drivers/spi/Makefile   |   1 +
 drivers/spi/fsl_dspi.c | 737 +
 include/fsl_dspi.h | 150 ++
 3 files changed, 888 insertions(+)
 create mode 100644 drivers/spi/fsl_dspi.c
 create mode 100644 include/fsl_dspi.h

diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index edbd520..9c2b8de 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_TI_QSPI) += ti_qspi.o
 obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o
 obj-$(CONFIG_ZYNQ_SPI) += zynq_spi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
+obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
new file mode 100644
index 000..6476f91
--- /dev/null
+++ b/drivers/spi/fsl_dspi.c
@@ -0,0 +1,737 @@
+/*
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * Copyright (C) 2004-2009, 2015 Freescale Semiconductor, Inc.
+ * TsiChung Liew (tsi-chung.l...@freescale.com)
+ * Chao Fu (b44...@freescale.com)
+ * Haikun Wang (b53...@freescale.com)
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include dm.h
+#include errno.h
+#include common.h
+#include spi.h
+#include malloc.h
+#include asm/io.h
+#include fdtdec.h
+#ifndef CONFIG_M68K
+#include asm/arch/clock.h
+#endif
+#include fsl_dspi.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* fsl_dspi_platdata flags */
+#define DSPI_FLAG_REGMAP_ENDIAN_BIG(1  0)
+
+/* idle data value */
+#define DSPI_IDLE_VAL  0x0
+
+/* max chipselect signals number */
+#define FSL_DSPI_MAX_CHIPSELECT6
+
+/* default SCK frequency, unit: HZ */
+#define FSL_DSPI_DEFAULT_SCK_FREQ  1000
+
+/* tx/rx data wait timeout value, unit: us */
+#define DSPI_TXRX_WAIT_TIMEOUT 100
+
+/* CTAR register pre-configure value */
+#define DSPI_CTAR_DEFAULT_VALUE(DSPI_CTAR_TRSZ(7) | \
+   DSPI_CTAR_PCSSCK_1CLK | \
+   DSPI_CTAR_PASC(0) | \
+   DSPI_CTAR_PDT(0) | \
+   DSPI_CTAR_CSSCK(0) | \
+   DSPI_CTAR_ASC(0) | \
+   DSPI_CTAR_DT(0))
+
+/* CTAR register pre-configure mask */
+#define DSPI_CTAR_SET_MODE_MASK(DSPI_CTAR_TRSZ(15) | \
+   DSPI_CTAR_PCSSCK(3) | \
+   DSPI_CTAR_PASC(3) | \
+   DSPI_CTAR_PDT(3) | \
+   DSPI_CTAR_CSSCK(15) | \
+   DSPI_CTAR_ASC(15) | \
+   DSPI_CTAR_DT(15))
+
+/**
+ * struct fsl_dspi_platdata - platform data for Freescale DSPI
+ *
+ * @flags: Flags for DSPI DSPI_FLAG_...
+ * @speed_hz: Default SCK frequency
+ * @num_chipselect: Number of DSPI chipselect signals
+ * @regs_addr: Base address of DSPI registers
+ */
+struct fsl_dspi_platdata {
+   uint flags;
+   uint speed_hz;
+   uint num_chipselect;
+   fdt_addr_t regs_addr;
+};
+
+/**
+ * struct fsl_dspi_priv - private data for Freescale DSPI
+ *
+ * @flags: Flags for DSPI DSPI_FLAG_...
+ * @mode: SPI mode to use for slave device (see SPI mode flags)
+ * @mcr_val: MCR register configure value
+ * @bus_clk: DSPI input clk frequency
+ * @speed_hz: Default SCK frequency
+ * @charbit: How many bits in every transfer
+ * @num_chipselect: Number of DSPI chipselect signals
+ * @ctar_val: CTAR register configure value of per chipselect slave device
+ * @regs: Point to DSPI register structure for I/O access
+ */
+struct fsl_dspi_priv {
+   uint flags;
+   uint mode;
+   uint mcr_val;
+   uint bus_clk;
+   uint speed_hz;
+   uint charbit;
+   uint num_chipselect;
+   uint ctar_val[FSL_DSPI_MAX_CHIPSELECT];
+   struct dspi *regs;
+};
+
+#ifndef CONFIG_DM_SPI
+struct fsl_dspi {
+   struct spi_slave slave;
+   struct fsl_dspi_priv priv;
+};
+#endif
+
+__weak void cpu_dspi_port_conf(void)
+{
+}
+
+__weak int cpu_dspi_claim_bus(uint bus, uint cs)
+{
+   return 0;
+}
+
+__weak void cpu_dspi_release_bus(uint bus, uint cs)
+{
+}
+
+static uint dspi_read32(uint flags, uint *addr)
+{
+   return