device model bring-up of ti-qspi on dra72, dra74 and am437x-sk evm
Subsystems (3)
v2 cover device model bring-up of ti-qspi on dra72, dra74 and am437x-sk evm
This patch series enables ti_qspi to adopt driver model. This has been tested on dra72, dra74 and am437x-sk evms (logs [1]). Also pushed a branch for testing [2]
[1]: http://pastebin.ubuntu.com/13099856/
[2]: git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git qspi-v2
Changes from Initial version:
* Split "prepare driver for DM conversion" for easier review
* added memory map mode to the driver
* Fixed the cosmetic reviews from Simon
* Modified the dev_get_addr_index to adopt OF_TRANSULATE as well and also removed code duplicate.
* Added compatibles for spi flashed found in DRA7xx and AM437x SK
Mugunthan V N (16):
drivers: spi: ti_qspi: do not hard code chip select for memory map
configuration
drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver
model conversion
drivers: spi: ti_qspi: prepare driver for DM conversion
dm: core: Add a new api to get indexed device address
spi: Add support for dual and quad mode
dra7xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
dts: dra7: add spi alias for qspi
drivers: spi: ti_qspi: convert driver to adopt device driver model
arm: dts: dra7: add qspi register maps for memory map and control
module
drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
drivers: mtd: spi: sf_probe: add compatible for Macronix spi flash
defconfig: dra72_evm: enable spi driver model
defconfig: dra74_evm: enable spi driver model
am43xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
arm: dts: am4372: add qspi register maps for memory map
defconfig: am437x_sk_evm: enable spi driver model
arch/arm/dts/am4372.dtsi | 4 +- arch/arm/dts/dra7.dtsi | 5 +- configs/am437x_sk_evm_defconfig | 3 + configs/dra72_evm_defconfig | 2 + configs/dra74_evm_defconfig | 2 + drivers/core/device.c | 16 +- drivers/mtd/spi/sf_probe.c | 2 + drivers/spi/spi-uclass.c | 33 +++ drivers/spi/ti_qspi.c | 515 ++++++++++++++++++++++++++++------------ include/configs/am43xx_evm.h | 2 + include/configs/dra7xx_evm.h | 5 + include/dm/device.h | 10 + include/spi.h | 4 + 13 files changed, 442 insertions(+), 161 deletions(-)
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 1/16 drivers: spi: ti_qspi: do not hard code chip select for memory map configuration
To enable memory map in dra7xx, specific chip select must be written to control module register. But this hard coded to chip select 1, fixing it by writing the specific chip select value to control module register.
--- drivers/spi/ti_qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/ti_qspi.c +2 -2
@@ -41,7 +41,7 @@#define QSPI_WC_BUSY (QSPI_WC | QSPI_BUSY)#define QSPI_XFER_DONE QSPI_WC#define MM_SWITCH 0x01 -#define MEM_CS 0x100 +#define MEM_CS (cs) ((cs + 1) << 8)#define MEM_CS_UNSELECT 0xfffff0ff#define MMAP_START_ADDR_DRA 0x5c000000#define MMAP_START_ADDR_AM43x 0x30000000
@@ -265,7 +265,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,writel (MM_SWITCH , &qslave->base->memswitch);#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) val =readl (CORE_CTRL_IO ); - val |=MEM_CS ; + val |=MEM_CS (slave->cs);writel (val,CORE_CTRL_IO );#endif return 0 ;
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 1/16 drivers: spi: ti_qspi: do not hard code chip select for memory map configuration
Quoted 9 lines · Mugunthan V N
To enable memory map in dra7xx, specific chip select must be written to control module register. But this hard coded to chip select 1, fixing it by writing the specific chip select value to control module register.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
But maybe it would be better to just drop the MEM_CS macro.
Quoted 24 lines
drivers/spi/ti_qspi.c +2
-3@@ -41,7 +41,7 @@#define QSPI_WC_BUSY (QSPI_WC | QSPI_BUSY)#define QSPI_XFER_DONE QSPI_WC#define MM_SWITCH 0x01 -#define MEM_CS 0x100 +#define MEM_CS (cs) ((cs + 1) << 8)#define MEM_CS_UNSELECT 0xfffff0ff#define MMAP_START_ADDR_DRA 0x5c000000#define MMAP_START_ADDR_AM43x 0x30000000@@ -265,7 +265,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,writel (MM_SWITCH , &qslave->base->memswitch);#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) val =readl (CORE_CTRL_IO ); - val |=MEM_CS ; + val |=MEM_CS (slave->cs);writel (val,CORE_CTRL_IO );#endif return 0 ; --
Quoted 2 lines
2.6.2.280.g74301d6
Regards,
Simon
PATCH v2 1/16 drivers: spi: ti_qspi: do not hard code chip select for memory map configuration
In reply to Mugunthan V NQuoted 6 lines · Mugunthan V N
To enable memory map in dra7xx, specific chip select must be written to control module register. But this hard coded to chip select 1, fixing it by writing the specific chip select value to control module register.
Signed-off-by Mugunthan V N <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/5aed7352/attachment.sig>
PATCH v2 1/16 drivers: spi: ti_qspi: do not hard code chip select for memory map configuration
Quoted 10 lines · Tom Rini
Quoted 6 lines · Mugunthan V N
To enable memory map in dra7xx, specific chip select must be written to control module register. But this hard coded to chip select 1, fixing it by writing the specific chip select value to control module register.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Tom Rini <[email protected]>
Signature · 1 line
Jagan.
PATCH v2 2/16 drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver model conversion
In reply to Mugunthan V NChanging the ti_qspi_priv structure and its instance names from to priv for driver mode conversion.
--- drivers/spi/ti_qspi.c | 118 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-)
drivers/spi/ti_qspi.c +59 -59
@@ -85,8 +85,8 @@ struct ti_qspi_regs {u32 data3; }; -/* ti qspi slave */ -struct ti_qspi_slave { +/* ti qspi priv */ +struct ti_qspi_priv {struct spi_slave slave;struct ti_qspi_regs *base;unsigned int mode;
@@ -94,14 +94,14 @@ struct ti_qspi_slave {u32 dc; }; -static inline struct ti_qspi_slave *to_ti_qspi_slave (struct spi_slave *slave) +static inline struct ti_qspi_priv *to_ti_qspi_priv (struct spi_slave *slave) { - return container_of(slave, struct ti_qspi_slave, slave); + return container_of(slave, struct ti_qspi_priv, slave); } -static void ti_spi_setup_spi_register (struct ti_qspi_slave *qslave) +static void ti_spi_setup_spi_register (struct ti_qspi_priv *priv) { -struct spi_slave *slave = &qslave->slave; +struct spi_slave *slave = &priv->slave;u32 memval =0 ;#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX )
@@ -123,12 +123,12 @@ static void ti_spi_setup_spi_register(struct ti_qspi_slave *qslave)QSPI_NUM_DUMMY_BITS ;#endif -writel (memval, &qslave->base->setup0); +writel (memval, &priv->base->setup0); }static void ti_spi_set_speed (struct spi_slave *slave,uint hz) { -struct ti_qspi_slave *qslave =to_ti_qspi_slave (slave); +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);uint clk_div;debug ("ti_spi_set_speed: hz: %d, clock divider %d\n" , hz, clk_div);
@@ -139,8 +139,8 @@ static void ti_spi_set_speed(struct spi_slave *slave, uint hz) clk_div = (QSPI_FCLK / hz) -1 ;/* disable SCLK */ -writel (readl (&qslave->base->clk_ctrl) & ~QSPI_CLK_EN , - &qslave->base->clk_ctrl); +writel (readl (&priv->base->clk_ctrl) & ~QSPI_CLK_EN , + &priv->base->clk_ctrl);/* assign clk_div values */ if (clk_div <0 )
@@ -149,7 +149,7 @@ static void ti_spi_set_speed(struct spi_slave *slave, uint hz) clk_div =QSPI_CLK_DIV_MAX ;/* enable SCLK */ -writel (QSPI_CLK_EN | clk_div, &qslave->base->clk_ctrl); +writel (QSPI_CLK_EN | clk_div, &priv->base->clk_ctrl); }int spi_cs_is_valid (unsigned int bus,unsigned int cs)
@@ -165,11 +165,11 @@ void spi_cs_activate(struct spi_slave *slave)void spi_cs_deactivate (struct spi_slave *slave) { -struct ti_qspi_slave *qslave =to_ti_qspi_slave (slave); +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);debug ("spi_cs_deactivate: 0x%08x\n" , (u32 )slave); -writel (qslave->cmd |QSPI_INVAL , &qslave->base->cmd); +writel (priv->cmd |QSPI_INVAL , &priv->base->cmd); }void spi_init (void )
@@ -180,73 +180,73 @@ void spi_init(void)struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs,unsigned int max_hz,unsigned int mode) { -struct ti_qspi_slave *qslave; +struct ti_qspi_priv *priv;#ifdef CONFIG_AM43XX gpio_request (CONFIG_QSPI_SEL_GPIO ,"qspi_gpio" );gpio_direction_output (CONFIG_QSPI_SEL_GPIO ,1 );#endif - qslave = spi_alloc_slave(struct ti_qspi_slave, bus, cs); -if (!qslave) { -printf ("SPI_error: Fail to allocate ti_qspi_slave\n" ); + priv = spi_alloc_slave(struct ti_qspi_priv, bus, cs); +if (!priv) { +printf ("SPI_error: Fail to allocate ti_qspi_priv\n" );return NULL ; } - qslave->base = (struct ti_qspi_regs *)QSPI_BASE ; - qslave->mode = mode; + priv->base = (struct ti_qspi_regs *)QSPI_BASE ; + priv->mode = mode; -ti_spi_set_speed (&qslave->slave, max_hz); +ti_spi_set_speed (&priv->slave, max_hz);#ifdef CONFIG_TI_SPI_MMAP -ti_spi_setup_spi_register (qslave); +ti_spi_setup_spi_register (priv);#endif -return &qslave->slave; +return &priv->slave; }void spi_free_slave (struct spi_slave *slave) { -struct ti_qspi_slave *qslave =to_ti_qspi_slave (slave); -free (qslave); +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); +free (priv); }int spi_claim_bus (struct spi_slave *slave) { -struct ti_qspi_slave *qslave =to_ti_qspi_slave (slave); +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);debug ("spi_claim_bus: bus:%i cs:%i\n" , slave->bus, slave->cs); - qslave->dc =0 ; -if (qslave->mode &SPI_CPHA ) - qslave->dc |=QSPI_CKPHA (slave->cs); -if (qslave->mode &SPI_CPOL ) - qslave->dc |=QSPI_CKPOL (slave->cs); -if (qslave->mode &SPI_CS_HIGH ) - qslave->dc |=QSPI_CSPOL (slave->cs); + priv->dc =0 ; +if (priv->mode &SPI_CPHA ) + priv->dc |=QSPI_CKPHA (slave->cs); +if (priv->mode &SPI_CPOL ) + priv->dc |=QSPI_CKPOL (slave->cs); +if (priv->mode &SPI_CS_HIGH ) + priv->dc |=QSPI_CSPOL (slave->cs); -writel (qslave->dc, &qslave->base->dc); -writel (0 , &qslave->base->cmd); -writel (0 , &qslave->base->data); +writel (priv->dc, &priv->base->dc); +writel (0 , &priv->base->cmd); +writel (0 , &priv->base->data);return 0 ; }void spi_release_bus (struct spi_slave *slave) { -struct ti_qspi_slave *qslave =to_ti_qspi_slave (slave); +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);debug ("spi_release_bus: bus:%i cs:%i\n" , slave->bus, slave->cs); -writel (0 , &qslave->base->dc); -writel (0 , &qslave->base->cmd); -writel (0 , &qslave->base->data); +writel (0 , &priv->base->dc); +writel (0 , &priv->base->cmd); +writel (0 , &priv->base->data); }int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout,void *din,unsigned long flags) { -struct ti_qspi_slave *qslave =to_ti_qspi_slave (slave); +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);uint words = bitlen >>3 ;/* fixed 8-bit word length */ const uchar *txp = dout;uchar *rxp = din;
@@ -262,7 +262,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,/* Setup mmap flags */ if (flags &SPI_XFER_MMAP ) { -writel (MM_SWITCH , &qslave->base->memswitch); +writel (MM_SWITCH , &priv->base->memswitch);#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) val =readl (CORE_CTRL_IO ); val |=MEM_CS (slave->cs);
@@ -270,7 +270,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,#endif return 0 ; }else if (flags &SPI_XFER_MMAP_END ) { -writel (~MM_SWITCH , &qslave->base->memswitch); +writel (~MM_SWITCH , &priv->base->memswitch);#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) val =readl (CORE_CTRL_IO ); val &=MEM_CS_UNSELECT ;
@@ -288,12 +288,12 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, }/* Setup command reg */ - qslave->cmd =0 ; - qslave->cmd |=QSPI_WLEN (8 ); - qslave->cmd |=QSPI_EN_CS (slave->cs); + priv->cmd =0 ; + priv->cmd |=QSPI_WLEN (8 ); + priv->cmd |=QSPI_EN_CS (slave->cs);if (flags &SPI_3WIRE ) - qslave->cmd |=QSPI_3_PIN ; - qslave->cmd |=0xfff ; + priv->cmd |=QSPI_3_PIN ; + priv->cmd |=0xfff ;/* FIXME: This delay is required for successfull * completion of read/write/erase. Once its root
@@ -305,39 +305,39 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,while (words--) {if (txp) {debug ("tx cmd %08x dc %08x data %02x\n" , - qslave->cmd |QSPI_WR_SNGL , qslave->dc, *txp); -writel (*txp++, &qslave->base->data); -writel (qslave->cmd |QSPI_WR_SNGL , - &qslave->base->cmd); - status =readl (&qslave->base->status); + priv->cmd |QSPI_WR_SNGL , priv->dc, *txp); +writel (*txp++, &priv->base->data); +writel (priv->cmd |QSPI_WR_SNGL , + &priv->base->cmd); + status =readl (&priv->base->status); timeout =QSPI_TIMEOUT ;while ((status &QSPI_WC_BUSY ) !=QSPI_XFER_DONE ) {if (--timeout <0 ) {printf ("spi_xfer: TX timeout!\n" );return -1 ; } - status =readl (&qslave->base->status); + status =readl (&priv->base->status); }debug ("tx done, status %08x\n" , status); }if (rxp) { - qslave->cmd |=QSPI_RD_SNGL ; + priv->cmd |=QSPI_RD_SNGL ;debug ("rx cmd %08x dc %08x\n" , - qslave->cmd, qslave->dc); + priv->cmd, priv->dc);#ifdef CONFIG_DRA7XX udelay (500 );#endif -writel (qslave->cmd, &qslave->base->cmd); - status =readl (&qslave->base->status); +writel (priv->cmd, &priv->base->cmd); + status =readl (&priv->base->status); timeout =QSPI_TIMEOUT ;while ((status &QSPI_WC_BUSY ) !=QSPI_XFER_DONE ) {if (--timeout <0 ) {printf ("spi_xfer: RX timeout!\n" );return -1 ; } - status =readl (&qslave->base->status); + status =readl (&priv->base->status); } - *rxp++ =readl (&qslave->base->data); + *rxp++ =readl (&priv->base->data);debug ("rx done, status %08x, read %02x\n" , status, *(rxp-1 )); }
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 2/16 drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver model conversion
Quoted 7 lines · Mugunthan V N
Changing the
ti_qspi_privstructure and its instance names from to priv for driver mode conversion.Signed-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 118 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-)
PATCH v2 2/16 drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver model conversion
In reply to Mugunthan V NQuoted 4 lines · Mugunthan V N
Changing the
ti_qspi_privstructure and its instance names from to priv for driver mode conversion.Signed-off-by Mugunthan V N <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/380fda7b/attachment.sig>
PATCH v2 2/16 drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver model conversion
Quoted 8 lines · Tom Rini
Quoted 4 lines · Mugunthan V N
Changing the
ti_qspi_privstructure and its instance names from to priv for driver mode conversion.Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Tom Rini <[email protected]>
Signature · 1 line
Jagan.
PATCH v2 3/16 drivers: spi: ti_qspi: prepare driver for DM conversion
In reply to Mugunthan V NPrepare driver for DM conversion.
--- drivers/spi/ti_qspi.c | 287 ++++++++++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 126 deletions(-)
drivers/spi/ti_qspi.c +161 -126
@@ -28,6 +28,7 @@#define QSPI_3_PIN BIT(18)#define QSPI_RD_SNGL BIT(16)#define QSPI_WR_SNGL (2 << 16) +#define QSPI_RD_DUAL (7 << 16)#define QSPI_INVAL (4 << 16)#define QSPI_RD_QUAD (7 << 16)/* device control */
@@ -89,46 +90,16 @@ struct ti_qspi_regs {struct ti_qspi_priv {struct spi_slave slave;struct ti_qspi_regs *base; +void *ctrl_mod_mmap;unsigned int mode;u32 cmd;u32 dc; +u32 num_cs; +u32 rx_bus_width; }; -static inline struct ti_qspi_priv *to_ti_qspi_priv (struct spi_slave *slave) -{ - return container_of(slave, struct ti_qspi_priv, slave); -} - -static void ti_spi_setup_spi_register (struct ti_qspi_priv *priv) -{ -struct spi_slave *slave = &priv->slave; -u32 memval =0 ; - -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) - slave->memory_map = (void *)MMAP_START_ADDR_DRA ; -#else - slave->memory_map = (void *)MMAP_START_ADDR_AM43x; -#endif - -#ifdef CONFIG_QSPI_QUAD_SUPPORT - memval |= (QSPI_CMD_READ_QUAD |QSPI_SETUP0_NUM_A_BYTES | -QSPI_SETUP0_NUM_D_BYTES_8_BITS | -QSPI_SETUP0_READ_QUAD |QSPI_CMD_WRITE | -QSPI_NUM_DUMMY_BITS ); - slave->op_mode_rx =SPI_OPM_RX_QOF ; -#else - memval |=QSPI_CMD_READ |QSPI_SETUP0_NUM_A_BYTES | -QSPI_SETUP0_NUM_D_BYTES_NO_BITS | -QSPI_SETUP0_READ_NORMAL |QSPI_CMD_WRITE | -QSPI_NUM_DUMMY_BITS ; -#endif - -writel (memval, &priv->base->setup0); -} - -static void ti_spi_set_speed (struct spi_slave *slave,uint hz) +static void ti_spi_set_speed (struct ti_qspi_priv *priv,uint hz) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);uint clk_div;debug ("ti_spi_set_speed: hz: %d, clock divider %d\n" , hz, clk_div);
@@ -152,130 +123,80 @@ static void ti_spi_set_speed(struct spi_slave *slave, uint hz)writel (QSPI_CLK_EN | clk_div, &priv->base->clk_ctrl); } -int spi_cs_is_valid (unsigned int bus,unsigned int cs) -{ -return 1 ; -} - -void spi_cs_activate (struct spi_slave *slave) +static void ti_qspi_cs_deactivate (struct ti_qspi_priv *priv) { -/* CS handled in xfer */ -return ; -} - -void spi_cs_deactivate (struct spi_slave *slave) -{ -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); - -debug ("spi_cs_deactivate: 0x%08x\n" , (u32 )slave); -writel (priv->cmd |QSPI_INVAL , &priv->base->cmd); } -void spi_init (void ) +static int __ti_qspi_set_mode (struct ti_qspi_priv *priv,unsigned int mode) { -/* nothing to do */ -} - -struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, -unsigned int max_hz,unsigned int mode) -{ -struct ti_qspi_priv *priv; - -#ifdef CONFIG_AM43XX -gpio_request (CONFIG_QSPI_SEL_GPIO ,"qspi_gpio" ); -gpio_direction_output (CONFIG_QSPI_SEL_GPIO ,1 ); -#endif - - priv = spi_alloc_slave(struct ti_qspi_priv, bus, cs); -if (!priv) { -printf ("SPI_error: Fail to allocate ti_qspi_priv\n" ); -return NULL ; - } - - priv->base = (struct ti_qspi_regs *)QSPI_BASE ; - priv->mode = mode; - -ti_spi_set_speed (&priv->slave, max_hz); - -#ifdef CONFIG_TI_SPI_MMAP -ti_spi_setup_spi_register (priv); -#endif - -return &priv->slave; -} - -void spi_free_slave (struct spi_slave *slave) -{ -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); -free (priv); + priv->dc =0 ; +if (mode &SPI_CPHA ) + priv->dc |=QSPI_CKPHA (0 ); +if (mode &SPI_CPOL ) + priv->dc |=QSPI_CKPOL (0 ); +if (mode &SPI_CS_HIGH ) + priv->dc |=QSPI_CSPOL (0 ); + +if (mode &SPI_RX_QUAD ) + priv->rx_bus_width =QSPI_RD_QUAD ; +else if (mode &SPI_RX_QUAD ) + priv->rx_bus_width =QSPI_RD_DUAL ; +else + priv->rx_bus_width =QSPI_RD_SNGL ; +return 0 ; } -int spi_claim_bus (struct spi_slave *slave) +static int __ti_qspi_claim_bus (struct ti_qspi_priv *priv,int cs) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); - -debug ("spi_claim_bus: bus:%i cs:%i\n" , slave->bus, slave->cs); - - priv->dc =0 ; -if (priv->mode &SPI_CPHA ) - priv->dc |=QSPI_CKPHA (slave->cs); -if (priv->mode &SPI_CPOL ) - priv->dc |=QSPI_CKPOL (slave->cs); -if (priv->mode &SPI_CS_HIGH ) - priv->dc |=QSPI_CSPOL (slave->cs); -writel (priv->dc, &priv->base->dc);writel (0 , &priv->base->cmd);writel (0 , &priv->base->data); + priv->dc <<= cs *8 ; +writel (priv->dc, &priv->base->dc);return 0 ; } -void spi_release_bus (struct spi_slave *slave) +static void __ti_qspi_release_bus (struct ti_qspi_priv *priv) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); - -debug ("spi_release_bus: bus:%i cs:%i\n" , slave->bus, slave->cs); -writel (0 , &priv->base->dc);writel (0 , &priv->base->cmd);writel (0 , &priv->base->data); } -int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, -void *din,unsigned long flags) +static void ti_qspi_ctrl_mode_mmap (void *ctrl_mod_mmap,int cs,bool enable) +{ +u32 val; + + val =readl (ctrl_mod_mmap); +if (enable) + val |=MEM_CS (cs); +else + val &=MEM_CS_UNSELECT ; +writel (val, ctrl_mod_mmap); +} + +static int __ti_qspi_xfer (struct ti_qspi_priv *priv,unsigned int bitlen, +const void *dout,void *din,unsigned long flags, +u32 cs) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);uint words = bitlen >>3 ;/* fixed 8-bit word length */ const uchar *txp = dout;uchar *rxp = din;uint status;int timeout; -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) -int val; -#endif - -debug ("spi_xfer: bus:%i cs:%i bitlen:%i words:%i flags:%lx\n" , - slave->bus, slave->cs, bitlen, words, flags); -/* Setup mmap flags */ if (flags &SPI_XFER_MMAP ) {writel (MM_SWITCH , &priv->base->memswitch); -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) - val =readl (CORE_CTRL_IO ); - val |=MEM_CS (slave->cs); -writel (val,CORE_CTRL_IO ); -#endif +if (priv->ctrl_mod_mmap) +ti_qspi_ctrl_mode_mmap (priv->ctrl_mod_mmap, cs, true);return 0 ; }else if (flags &SPI_XFER_MMAP_END ) {writel (~MM_SWITCH , &priv->base->memswitch); -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) - val =readl (CORE_CTRL_IO ); - val &=MEM_CS_UNSELECT ; -writel (val,CORE_CTRL_IO ); -#endif +if (priv->ctrl_mod_mmap) +ti_qspi_ctrl_mode_mmap (priv->ctrl_mod_mmap, cs, false);return 0 ; }
@@ -290,7 +211,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,/* Setup command reg */ priv->cmd =0 ; priv->cmd |=QSPI_WLEN (8 ); - priv->cmd |=QSPI_EN_CS (slave->cs); + priv->cmd |=QSPI_EN_CS (cs);if (flags &SPI_3WIRE ) priv->cmd |=QSPI_3_PIN ; priv->cmd |=0xfff ;
@@ -345,7 +266,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,/* Terminate frame */ if (flags &SPI_XFER_END ) -spi_cs_deactivate (slave); +ti_qspi_cs_deactivate (priv);return 0 ; }
@@ -372,3 +293,117 @@ void spi_flash_copy_mmap(void *data, void *offset, size_t len) *((unsigned int *)offset) += len; }#endif + +static inline struct ti_qspi_priv *to_ti_qspi_priv (struct spi_slave *slave) +{ + return container_of(slave, struct ti_qspi_priv, slave); +} + +int spi_cs_is_valid (unsigned int bus,unsigned int cs) +{ +return 1 ; +} + +void spi_cs_activate (struct spi_slave *slave) +{ +/* CS handled in xfer */ +return ; +} + +void spi_cs_deactivate (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); +ti_qspi_cs_deactivate (priv); +} + +void spi_init (void ) +{ +/* nothing to do */ +} + +static void ti_spi_setup_spi_register (struct ti_qspi_priv *priv) +{ +u32 memval =0 ; + +#ifdef CONFIG_QSPI_QUAD_SUPPORT +struct spi_slave *slave = &priv->slave; + memval |= (QSPI_CMD_READ_QUAD |QSPI_SETUP0_NUM_A_BYTES | +QSPI_SETUP0_NUM_D_BYTES_8_BITS | +QSPI_SETUP0_READ_QUAD |QSPI_CMD_WRITE | +QSPI_NUM_DUMMY_BITS ); + slave->op_mode_rx =SPI_OPM_RX_QOF ; +#else + memval |=QSPI_CMD_READ |QSPI_SETUP0_NUM_A_BYTES | +QSPI_SETUP0_NUM_D_BYTES_NO_BITS | +QSPI_SETUP0_READ_NORMAL |QSPI_CMD_WRITE | +QSPI_NUM_DUMMY_BITS ; +#endif + +writel (memval, &priv->base->setup0); +} + +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, +unsigned int max_hz,unsigned int mode) +{ +struct ti_qspi_priv *priv; + +#ifdef CONFIG_AM43XX +gpio_request (CONFIG_QSPI_SEL_GPIO ,"qspi_gpio" ); +gpio_direction_output (CONFIG_QSPI_SEL_GPIO ,1 ); +#endif + + priv = spi_alloc_slave(struct ti_qspi_priv, bus, cs); +if (!priv) { +printf ("SPI_error: Fail to allocate ti_qspi_priv\n" ); +return NULL ; + } + + priv->base = (struct ti_qspi_regs *)QSPI_BASE ; + priv->mode = mode; +#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) + priv->ctrl_mod_mmap = (void *)CORE_CTRL_IO ; + priv->slave.memory_map = (void *)MMAP_START_ADDR_DRA ; +#else + priv->slave.memory_map = (void *)MMAP_START_ADDR_AM43x; +#endif + +ti_spi_set_speed (priv, max_hz); + +#ifdef CONFIG_TI_SPI_MMAP +ti_spi_setup_spi_register (priv); +#endif + +return &priv->slave; +} + +void spi_free_slave (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); +free (priv); +} + +int spi_claim_bus (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); + +debug ("%s: bus:%i cs:%i\n" , __func__, priv->slave.bus, priv->slave.cs); +__ti_qspi_set_mode (priv, priv->mode); +return __ti_qspi_claim_bus (priv, priv->slave.cs); +} +void spi_release_bus (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); + +debug ("%s: bus:%i cs:%i\n" , __func__, priv->slave.bus, priv->slave.cs); +__ti_qspi_release_bus (priv); +} + +int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, +void *din,unsigned long flags) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); + +debug ("spi_xfer: bus:%i cs:%i bitlen:%i flags:%lx\n" , + priv->slave.bus, priv->slave.cs, bitlen, flags); +return __ti_qspi_xfer (priv, bitlen, dout, din, flags, priv->slave.cs); +}
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 3/16 drivers: spi: ti_qspi: prepare driver for DM conversion
Hi Mugunthan,
Quoted 6 lines · Mugunthan V N
Prepare driver for DM conversion.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 287 ++++++++++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 126 deletions(-)
This looks OK except for the lack of a change log and one thing below.
Quoted 14 lines
drivers/spi/ti_qspi.c +1
-0@@ -28,6 +28,7 @@#define QSPI_3_PIN BIT(18)#define QSPI_RD_SNGL BIT(16)#define QSPI_WR_SNGL (2 << 16) +#define QSPI_RD_DUAL (7 << 16)#define QSPI_INVAL (4 << 16)#define QSPI_RD_QUAD (7 << 16)/* device control */
drivers/spi/ti_qspi.c struct ti_qspi_regs { · line 91
Quoted 2 lines
drivers/spi/ti_qspi.c +0
-0@@ -89,46 +90,16 @@ struct ti_qspi_regs {struct ti_qspi_priv {struct spi_slave slave;
This should not be present when driver model is used. Can you put an #ifdef around it and store anything else you need directly in the structure, rather than using struct spi_slave?
Quoted 9 lines
drivers/spi/ti_qspi.c +3
-0struct ti_qspi_regs *base; +void *ctrl_mod_mmap;unsigned int mode;u32 cmd;u32 dc; +u32 num_cs; +u32 rx_bus_width; };
PATCH v2 3/16 drivers: spi: ti_qspi: prepare driver for DM conversion
Quoted 23 lines · Simon Glass
Hi Mugunthan,
Quoted 6 lines · Mugunthan V N
Prepare driver for DM conversion.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 287 ++++++++++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 126 deletions(-)This looks OK except for the lack of a change log and one thing below.
Quoted 12 lines
drivers/spi/ti_qspi.c +1
-0@@ -28,6 +28,7 @@#define QSPI_3_PIN BIT(18)#define QSPI_RD_SNGL BIT(16)#define QSPI_WR_SNGL (2 << 16) +#define QSPI_RD_DUAL (7 << 16)#define QSPI_INVAL (4 << 16)#define QSPI_RD_QUAD (7 << 16)
Quoted 8 lines
drivers/spi/ti_qspi.c struct ti_qspi_regs { · line 91
Quoted 4 lines
drivers/spi/ti_qspi.c +0
-0/* device control */ @@ -89,46 +90,16 @@ struct ti_qspi_regs {struct ti_qspi_priv {struct spi_slave slave;This should not be present when driver model is used. Can you put an #ifdef around it and store anything else you need directly in the structure, rather than using struct
spi_slave?
Yeah, will do it in next version.
Quoted 10 lines
drivers/spi/ti_qspi.c struct ti_qspi_regs { · line 100
Quoted 10 lines
drivers/spi/ti_qspi.c +3
-0struct ti_qspi_regs *base; +void *ctrl_mod_mmap;unsigned int mode;u32 cmd;u32 dc; +u32 num_cs; +u32 rx_bus_width; };
Regards
Mugunthan V N
PATCH v2 3/16 drivers: spi: ti_qspi: prepare driver for DM conversion
In reply to Mugunthan V NQuoted 20 lines · Mugunthan V N
Prepare driver for DM conversion.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 287 ++++++++++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 126 deletions(-)drivers/spi/ti_qspi.c +1
-0@@ -28,6 +28,7 @@#define QSPI_3_PIN BIT(18)#define QSPI_RD_SNGL BIT(16)#define QSPI_WR_SNGL (2 << 16) +#define QSPI_RD_DUAL (7 << 16)#define QSPI_INVAL (4 << 16)#define QSPI_RD_QUAD (7 << 16)/* device control */
drivers/spi/ti_qspi.c struct ti_qspi_regs { · line 93
Quoted 4 lines
drivers/spi/ti_qspi.c +1
-0@@ -89,46 +90,16 @@ struct ti_qspi_regs {struct ti_qspi_priv {struct spi_slave slave;struct ti_qspi_regs *base; +void *ctrl_mod_mmap;
Looks like this patch manages to prepare for non-dm addition by using dm functions is it? and other than that some new things got added like RD_DUAL or ctrl_mod_mmap, please add them separately add do the dm conversion only on existing code.
Quoted 360 lines
drivers/spi/ti_qspi.c +159
-127unsigned int mode;u32 cmd;u32 dc; +u32 num_cs; +u32 rx_bus_width; }; -static inline struct ti_qspi_priv *to_ti_qspi_priv (struct spi_slave *slave) -{ - return container_of(slave, struct ti_qspi_priv, slave); -} - -static void ti_spi_setup_spi_register (struct ti_qspi_priv *priv) -{ -struct spi_slave *slave = &priv->slave; -u32 memval =0 ; - -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) - slave->memory_map = (void *)MMAP_START_ADDR_DRA ; -#else - slave->memory_map = (void *)MMAP_START_ADDR_AM43x; -#endif - -#ifdef CONFIG_QSPI_QUAD_SUPPORT - memval |= (QSPI_CMD_READ_QUAD |QSPI_SETUP0_NUM_A_BYTES | -QSPI_SETUP0_NUM_D_BYTES_8_BITS | -QSPI_SETUP0_READ_QUAD |QSPI_CMD_WRITE | -QSPI_NUM_DUMMY_BITS ); - slave->op_mode_rx =SPI_OPM_RX_QOF ; -#else - memval |=QSPI_CMD_READ |QSPI_SETUP0_NUM_A_BYTES | -QSPI_SETUP0_NUM_D_BYTES_NO_BITS | -QSPI_SETUP0_READ_NORMAL |QSPI_CMD_WRITE | -QSPI_NUM_DUMMY_BITS ; -#endif - -writel (memval, &priv->base->setup0); -} - -static void ti_spi_set_speed (struct spi_slave *slave,uint hz) +static void ti_spi_set_speed (struct ti_qspi_priv *priv,uint hz) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);uint clk_div;debug ("ti_spi_set_speed: hz: %d, clock divider %d\n" , hz, clk_div);@@ -152,130 +123,80 @@ static void ti_spi_set_speed(struct spi_slave *slave, uint hz)writel (QSPI_CLK_EN | clk_div, &priv->base->clk_ctrl); } -int spi_cs_is_valid (unsigned int bus,unsigned int cs) -{ -return 1 ; -} - -void spi_cs_activate (struct spi_slave *slave) +static void ti_qspi_cs_deactivate (struct ti_qspi_priv *priv) { -/* CS handled in xfer */ -return ; -} - -void spi_cs_deactivate (struct spi_slave *slave) -{ -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); - -debug ("spi_cs_deactivate: 0x%08x\n" , (u32 )slave); -writel (priv->cmd |QSPI_INVAL , &priv->base->cmd); } -void spi_init (void ) +static int __ti_qspi_set_mode (struct ti_qspi_priv *priv,unsigned int mode) { -/* nothing to do */ -} - -struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, -unsigned int max_hz,unsigned int mode) -{ -struct ti_qspi_priv *priv; - -#ifdef CONFIG_AM43XX -gpio_request (CONFIG_QSPI_SEL_GPIO ,"qspi_gpio" ); -gpio_direction_output (CONFIG_QSPI_SEL_GPIO ,1 ); -#endif - - priv = spi_alloc_slave(struct ti_qspi_priv, bus, cs); -if (!priv) { -printf ("SPI_error: Fail to allocate ti_qspi_priv\n" ); -return NULL ; - } - - priv->base = (struct ti_qspi_regs *)QSPI_BASE ; - priv->mode = mode; - -ti_spi_set_speed (&priv->slave, max_hz); - -#ifdef CONFIG_TI_SPI_MMAP -ti_spi_setup_spi_register (priv); -#endif - -return &priv->slave; -} - -void spi_free_slave (struct spi_slave *slave) -{ -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); -free (priv); + priv->dc =0 ; +if (mode &SPI_CPHA ) + priv->dc |=QSPI_CKPHA (0 ); +if (mode &SPI_CPOL ) + priv->dc |=QSPI_CKPOL (0 ); +if (mode &SPI_CS_HIGH ) + priv->dc |=QSPI_CSPOL (0 ); + +if (mode &SPI_RX_QUAD ) + priv->rx_bus_width =QSPI_RD_QUAD ; +else if (mode &SPI_RX_QUAD ) + priv->rx_bus_width =QSPI_RD_DUAL ; +else + priv->rx_bus_width =QSPI_RD_SNGL ; +return 0 ; } -int spi_claim_bus (struct spi_slave *slave) +static int __ti_qspi_claim_bus (struct ti_qspi_priv *priv,int cs) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); - -debug ("spi_claim_bus: bus:%i cs:%i\n" , slave->bus, slave->cs); - - priv->dc =0 ; -if (priv->mode &SPI_CPHA ) - priv->dc |=QSPI_CKPHA (slave->cs); -if (priv->mode &SPI_CPOL ) - priv->dc |=QSPI_CKPOL (slave->cs); -if (priv->mode &SPI_CS_HIGH ) - priv->dc |=QSPI_CSPOL (slave->cs); -writel (priv->dc, &priv->base->dc);writel (0 , &priv->base->cmd);writel (0 , &priv->base->data); + priv->dc <<= cs *8 ; +writel (priv->dc, &priv->base->dc);return 0 ; } -void spi_release_bus (struct spi_slave *slave) +static void __ti_qspi_release_bus (struct ti_qspi_priv *priv) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); - -debug ("spi_release_bus: bus:%i cs:%i\n" , slave->bus, slave->cs); -writel (0 , &priv->base->dc);writel (0 , &priv->base->cmd);writel (0 , &priv->base->data); } -int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, -void *din,unsigned long flags) +static void ti_qspi_ctrl_mode_mmap (void *ctrl_mod_mmap,int cs,bool enable) +{ +u32 val; + + val =readl (ctrl_mod_mmap); +if (enable) + val |=MEM_CS (cs); +else + val &=MEM_CS_UNSELECT ; +writel (val, ctrl_mod_mmap); +} + +static int __ti_qspi_xfer (struct ti_qspi_priv *priv,unsigned int bitlen, +const void *dout,void *din,unsigned long flags, +u32 cs) { -struct ti_qspi_priv *priv =to_ti_qspi_priv (slave);uint words = bitlen >>3 ;/* fixed 8-bit word length */ const uchar *txp = dout;uchar *rxp = din;uint status;int timeout; -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) -int val; -#endif - -debug ("spi_xfer: bus:%i cs:%i bitlen:%i words:%i flags:%lx\n" , - slave->bus, slave->cs, bitlen, words, flags); -/* Setup mmap flags */ if (flags &SPI_XFER_MMAP ) {writel (MM_SWITCH , &priv->base->memswitch); -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) - val =readl (CORE_CTRL_IO ); - val |=MEM_CS (slave->cs); -writel (val,CORE_CTRL_IO ); -#endif +if (priv->ctrl_mod_mmap) +ti_qspi_ctrl_mode_mmap (priv->ctrl_mod_mmap, cs, true);return 0 ; }else if (flags &SPI_XFER_MMAP_END ) {writel (~MM_SWITCH , &priv->base->memswitch); -#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) - val =readl (CORE_CTRL_IO ); - val &=MEM_CS_UNSELECT ; -writel (val,CORE_CTRL_IO ); -#endif +if (priv->ctrl_mod_mmap) +ti_qspi_ctrl_mode_mmap (priv->ctrl_mod_mmap, cs, false);return 0 ; }@@ -290,7 +211,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,/* Setup command reg */ priv->cmd =0 ; priv->cmd |=QSPI_WLEN (8 ); - priv->cmd |=QSPI_EN_CS (slave->cs); + priv->cmd |=QSPI_EN_CS (cs);if (flags &SPI_3WIRE ) priv->cmd |=QSPI_3_PIN ; priv->cmd |=0xfff ;@@ -345,7 +266,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,/* Terminate frame */ if (flags &SPI_XFER_END ) -spi_cs_deactivate (slave); +ti_qspi_cs_deactivate (priv);return 0 ; }@@ -372,3 +293,117 @@ void spi_flash_copy_mmap(void *data, void *offset, size_t len) *((unsigned int *)offset) += len; }#endif + +static inline struct ti_qspi_priv *to_ti_qspi_priv (struct spi_slave *slave) +{ + return container_of(slave, struct ti_qspi_priv, slave); +} + +int spi_cs_is_valid (unsigned int bus,unsigned int cs) +{ +return 1 ; +} + +void spi_cs_activate (struct spi_slave *slave) +{ +/* CS handled in xfer */ +return ; +} + +void spi_cs_deactivate (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); +ti_qspi_cs_deactivate (priv); +} + +void spi_init (void ) +{ +/* nothing to do */ +} + +static void ti_spi_setup_spi_register (struct ti_qspi_priv *priv) +{ +u32 memval =0 ; + +#ifdef CONFIG_QSPI_QUAD_SUPPORT +struct spi_slave *slave = &priv->slave; + memval |= (QSPI_CMD_READ_QUAD |QSPI_SETUP0_NUM_A_BYTES | +QSPI_SETUP0_NUM_D_BYTES_8_BITS | +QSPI_SETUP0_READ_QUAD |QSPI_CMD_WRITE | +QSPI_NUM_DUMMY_BITS ); + slave->op_mode_rx =SPI_OPM_RX_QOF ; +#else + memval |=QSPI_CMD_READ |QSPI_SETUP0_NUM_A_BYTES | +QSPI_SETUP0_NUM_D_BYTES_NO_BITS | +QSPI_SETUP0_READ_NORMAL |QSPI_CMD_WRITE | +QSPI_NUM_DUMMY_BITS ; +#endif + +writel (memval, &priv->base->setup0); +} + +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, +unsigned int max_hz,unsigned int mode) +{ +struct ti_qspi_priv *priv; + +#ifdef CONFIG_AM43XX +gpio_request (CONFIG_QSPI_SEL_GPIO ,"qspi_gpio" ); +gpio_direction_output (CONFIG_QSPI_SEL_GPIO ,1 ); +#endif + + priv = spi_alloc_slave(struct ti_qspi_priv, bus, cs); +if (!priv) { +printf ("SPI_error: Fail to allocate ti_qspi_priv\n" ); +return NULL ; + } + + priv->base = (struct ti_qspi_regs *)QSPI_BASE ; + priv->mode = mode; +#if defined(CONFIG_DRA7XX ) || defined(CONFIG_AM57XX ) + priv->ctrl_mod_mmap = (void *)CORE_CTRL_IO ; + priv->slave.memory_map = (void *)MMAP_START_ADDR_DRA ; +#else + priv->slave.memory_map = (void *)MMAP_START_ADDR_AM43x; +#endif + +ti_spi_set_speed (priv, max_hz); + +#ifdef CONFIG_TI_SPI_MMAP +ti_spi_setup_spi_register (priv); +#endif + +return &priv->slave; +} + +void spi_free_slave (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); +free (priv); +} + +int spi_claim_bus (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); + +debug ("%s: bus:%i cs:%i\n" , __func__, priv->slave.bus, priv->slave.cs); +__ti_qspi_set_mode (priv, priv->mode); +return __ti_qspi_claim_bus (priv, priv->slave.cs); +} +void spi_release_bus (struct spi_slave *slave) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); + +debug ("%s: bus:%i cs:%i\n" , __func__, priv->slave.bus, priv->slave.cs); +__ti_qspi_release_bus (priv); +} + +int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, +void *din,unsigned long flags) +{ +struct ti_qspi_priv *priv =to_ti_qspi_priv (slave); + +debug ("spi_xfer: bus:%i cs:%i bitlen:%i flags:%lx\n" , + priv->slave.bus, priv->slave.cs, bitlen, flags); +return __ti_qspi_xfer (priv, bitlen, dout, din, flags, priv->slave.cs); +} --2.6.2.280.g74301d6
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 1 line
Jagan | openedev.
PATCH v2 3/16 drivers: spi: ti_qspi: prepare driver for DM conversion
Quoted 22 lines · Jagan Teki
Quoted 21 lines · Mugunthan V N
Prepare driver for DM conversion.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 287 ++++++++++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 126 deletions(-)drivers/spi/ti_qspi.c +1
-0@@ -28,6 +28,7 @@#define QSPI_3_PIN BIT(18)#define QSPI_RD_SNGL BIT(16)#define QSPI_WR_SNGL (2 << 16) +#define QSPI_RD_DUAL (7 << 16)#define QSPI_INVAL (4 << 16)#define QSPI_RD_QUAD (7 << 16)/* device control */ @@ -89,46 +90,16 @@ struct ti_qspi_regs {struct ti_qspi_priv {
Quoted 9 lines
drivers/spi/ti_qspi.c struct ti_qspi_regs { · line 93
Quoted 3 lines
drivers/spi/ti_qspi.c +1
-0struct spi_slave slave;struct ti_qspi_regs *base; +void *ctrl_mod_mmap;Looks like this patch manages to prepare for non-dm addition by using dm functions is it? and other than that some new things got added like
RD_DUALorctrl_mod_mmap, please add them separately add do the dm conversion only on existing code.
Will move all DM variables under #ifdef.
Regards
Mugunthan V N
PATCH v2 3/16 drivers: spi: ti_qspi: prepare driver for DM conversion
In reply to Jagan TekiJagan
Quoted 6 lines · Jagan Teki
Quoted 1 line
+ void
*ctrl_mod_mmap;Looks like this patch manages to prepare for non-dm addition by using dm functions is it? and other than that some new things got added like
RD_DUALorctrl_mod_mmap, please add them separately add do the dm conversion only on existing code.
ctrl_mod_map is used in non DM mode as well. Earlier there was a define, I changed it to a variable while preparing driver for DM conversion.
Regards
Mugunthan V N
PATCH v2 4/16 dm: core: Add a new api to get indexed device address
In reply to Mugunthan V NAdd new api to get device address based on index.
--- drivers/core/device.c | 16 ++++++++++++---- include/dm/device.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-)
drivers/core/device.c +12 -4
@@ -581,18 +581,21 @@ const char *dev_get_uclass_name(struct udevice *dev)return dev->uclass->uc_drv->name; } -fdt_addr_t dev_get_addr (struct udevice *dev) +fdt_addr_t dev_get_addr_index (struct udevice *dev,int index) {#if CONFIG_IS_ENABLED (OF_CONTROL )fdt_addr_t addr;if (CONFIG_IS_ENABLED (OF_TRANSLATE )) {const fdt32_t *reg; +int len =0 ; - reg =fdt_getprop (gd->fdt_blob, dev->of_offset,"reg" ,NULL ); -if (!reg) + reg =fdt_getprop (gd->fdt_blob, dev->of_offset,"reg" , &len); +if (!reg || (len <= (index *sizeof (fdt32_t) *2 )))return FDT_ADDR_T_NONE ; + reg += index *2 ; +/* * Use the full-fledged translate function for complex * bus setups.
@@ -608,7 +611,7 @@ fdt_addr_t dev_get_addr(struct udevice *dev) addr =fdtdec_get_addr_size_auto_parent (gd->fdt_blob, dev->parent->of_offset, dev->of_offset,"reg" , -0 ,NULL ); + index,NULL );if (CONFIG_IS_ENABLED (SIMPLE_BUS ) && addr !=FDT_ADDR_T_NONE ) {if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr);
@@ -620,6 +623,11 @@ fdt_addr_t dev_get_addr(struct udevice *dev)#endif } +fdt_addr_t dev_get_addr (struct udevice *dev) +{ +return dev_get_addr_index (dev,0 ); +} +bool device_has_children (struct udevice *dev) {return !list_empty (&dev->child_head);
include/dm/device.h +10 -0
@@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);fdt_addr_t dev_get_addr (struct udevice *dev);/** +* dev_get_addr() - Get the reg property of a device +* +* @dev: Pointer to a device +* @index: reg address array index +* +* @return addr +*/ +fdt_addr_t dev_get_addr_index (struct udevice *dev,int index); + +/** * device_has_children() - check if a device has any children * * @dev: Device to check
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 4/16 dm: core: Add a new api to get indexed device address
+Stephen
Hi,
Quoted 7 lines · Mugunthan V N
Add new api to get device address based on index.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/core/device.c | 16 ++++++++++++---- include/dm/device.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-)
You are touching critical core code so I think we need to be careful here.
Quoted 17 lines
drivers/core/device.c +1
-1@@ -581,18 +581,21 @@ const char *dev_get_uclass_name(struct udevice *dev)return dev->uclass->uc_drv->name; } -fdt_addr_t dev_get_addr (struct udevice *dev) +fdt_addr_t dev_get_addr_index (struct udevice *dev,int index) {#if CONFIG_IS_ENABLED (OF_CONTROL )fdt_addr_t addr;if (CONFIG_IS_ENABLED (OF_TRANSLATE )) {const fdt32_t *reg;
drivers/core/device.c const char *dev_get_uclass_name(struct udevice *dev) · line 598
Quoted 10 lines
drivers/core/device.c +5
-2+int len =0 ; - reg =fdt_getprop (gd->fdt_blob, dev->of_offset,"reg" ,NULL ); -if (!reg) + reg =fdt_getprop (gd->fdt_blob, dev->of_offset,"reg" , &len); +if (!reg || (len <= (index *sizeof (fdt32_t) *2 )))return FDT_ADDR_T_NONE ; + reg += index *2 ; +
This seems to be assuming that the address and size each occupy a single cell, but that is not the case in general (e.g. with 64-bit machines).
I think you need to call fdt_addr_cells() and fdt_size_cells(). See fdtdec_get_addr_size_auto_parent() as an example.
Quoted 29 lines
drivers/core/device.c +6
-1/* * Use the full-fledged translate function for complex * bus setups. @@ -608,7 +611,7 @@ fdt_addr_t dev_get_addr(struct udevice *dev) addr =fdtdec_get_addr_size_auto_parent (gd->fdt_blob, dev->parent->of_offset, dev->of_offset,"reg" , -0 ,NULL ); + index,NULL );if (CONFIG_IS_ENABLED (SIMPLE_BUS ) && addr !=FDT_ADDR_T_NONE ) {if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr);@@ -620,6 +623,11 @@ fdt_addr_t dev_get_addr(struct udevice *dev)#endif } +fdt_addr_t dev_get_addr (struct udevice *dev) +{ +return dev_get_addr_index (dev,0 ); +} +bool device_has_children (struct udevice *dev) {return !list_empty (&dev->child_head);include/dm/device.h +0
-0
include/dm/device.h int device_find_next_child(struct udevice **devp); · line 457
Quoted 4 lines
include/dm/device.h +1
-0@@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);fdt_addr_t dev_get_addr (struct udevice *dev);/** +* dev_get_addr() - Get the reg property of a device
dev_get_addr_index
include/dm/device.h int device_find_next_child(struct udevice **devp); · line 460
Quoted 3 lines
include/dm/device.h +3
-0+* +* @dev: Pointer to a device +* @index: reg address array index
I don't think this is sufficiently clear. Can you add a comment saying that the 'reg' property can hold a list of <addr, size> pairs and @index is used to select which one is used?
Quoted 10 lines
include/dm/device.h +6
-1+* +* @return addr +*/ +fdt_addr_t dev_get_addr_index (struct udevice *dev,int index); + +/** * device_has_children() - check if a device has any children * * @dev: Device to check --
Quoted 2 lines
2.6.2.280.g74301d6
Regards,
Simon
PATCH v2 4/16 dm: core: Add a new api to get indexed device address
Quoted 7 lines · Simon Glass
+Stephen
Hi,
Quoted 2 lines · Mugunthan V N
Add new api to get device address based on index.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Mugunthan V N <[email protected]>--- drivers/core/device.c | 16 ++++++++++++---- include/dm/device.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-)You are touching critical core code so I think we need to be careful here.
Okay
Quoted 32 lines
Quoted 17 lines
drivers/core/device.c +1
-1@@ -581,18 +581,21 @@ const char *dev_get_uclass_name(struct udevice *dev)return dev->uclass->uc_drv->name; } -fdt_addr_t dev_get_addr (struct udevice *dev) +fdt_addr_t dev_get_addr_index (struct udevice *dev,int index) {#if CONFIG_IS_ENABLED (OF_CONTROL )fdt_addr_t addr;if (CONFIG_IS_ENABLED (OF_TRANSLATE )) {const fdt32_t *reg;drivers/core/device.c const char *dev_get_uclass_name(struct udevice *dev) · line 598
Quoted 10 lines
drivers/core/device.c +5
-2+int len =0 ; - reg =fdt_getprop (gd->fdt_blob, dev->of_offset,"reg" ,NULL ); -if (!reg) + reg =fdt_getprop (gd->fdt_blob, dev->of_offset,"reg" , &len); +if (!reg || (len <= (index *sizeof (fdt32_t) *2 )))return FDT_ADDR_T_NONE ; + reg += index *2 ; +This seems to be assuming that the address and size each occupy a single cell, but that is not the case in general (e.g. with 64-bit machines).
Quoted 3 lines
I think you need to call
fdt_addr_cells()andfdt_size_cells(). Seefdtdec_get_addr_size_auto_parent()as an example.
Okay, will use these in next version.
Quoted 36 lines
Quoted 29 lines
drivers/core/device.c +6
-1/* * Use the full-fledged translate function for complex * bus setups. @@ -608,7 +611,7 @@ fdt_addr_t dev_get_addr(struct udevice *dev) addr =fdtdec_get_addr_size_auto_parent (gd->fdt_blob, dev->parent->of_offset, dev->of_offset,"reg" , -0 ,NULL ); + index,NULL );if (CONFIG_IS_ENABLED (SIMPLE_BUS ) && addr !=FDT_ADDR_T_NONE ) {if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr);@@ -620,6 +623,11 @@ fdt_addr_t dev_get_addr(struct udevice *dev)#endif } +fdt_addr_t dev_get_addr (struct udevice *dev) +{ +return dev_get_addr_index (dev,0 ); +} +bool device_has_children (struct udevice *dev) {return !list_empty (&dev->child_head);include/dm/device.h +0
-0include/dm/device.h int device_find_next_child(struct udevice **devp); · line 457
Quoted 4 lines
include/dm/device.h +1
-0@@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);fdt_addr_t dev_get_addr (struct udevice *dev);/** +* dev_get_addr() - Get the reg property of a device
dev_get_addr_index
Quoted 8 lines
include/dm/device.h int device_find_next_child(struct udevice **devp); · line 460
Quoted 3 lines
include/dm/device.h +3
-0+* +* @dev: Pointer to a device +* @index: reg address array index I don't think this is sufficiently clear. Can you add a comment saying that the 'reg' property can hold a list of <addr, size> pairs and @index is used to select which one is used?
Will add more doc in next version
Regards
Mugunthan V N
PATCH v2 5/16 spi: Add support for dual and quad mode
In reply to Mugunthan V Nspi bus can support dual and quad wire data transfers for tx and rx. So defining dual and quad modes for both tx and rx. Also add support to parse bus width used for spi tx and rx transfers.
--- drivers/spi/spi-uclass.c | 33 +++++++++++++++++++++++++++++++++ include/spi.h | 4 ++++ 2 files changed, 37 insertions(+)
drivers/spi/spi-uclass.c +33 -0
@@ -349,6 +349,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, struct dm_spi_slave_platdata *plat) {int mode =0 ; +int value; plat->cs =fdtdec_get_int (blob, node,"reg" ,-1 ); plat->max_hz =fdtdec_get_int (blob, node,"spi-max-frequency" ,0 );
@@ -360,6 +361,38 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, mode |=SPI_CS_HIGH ;if (fdtdec_get_bool (blob, node,"spi-half-duplex" )) mode |=SPI_PREAMBLE ; + +/* Device DUAL/QUAD mode */ + value =fdtdec_get_int (blob, node,"spi-tx-bus-width" ,1 ); +switch (value) { +case 1 : +break ; +case 2 : + mode |=SPI_TX_DUAL ; +break ; +case 4 : + mode |=SPI_TX_QUAD ; +break ; +default : +error ("spi-tx-bus-width %d not supported\n" , value); +break ; + } + + value =fdtdec_get_int (blob, node,"spi-rx-bus-width" ,1 ); +switch (value) { +case 1 : +break ; +case 2 : + mode |=SPI_RX_DUAL ; +break ; +case 4 : + mode |=SPI_RX_QUAD ; +break ; +default : +error ("spi-rx-bus-width %d not supported\n" , value); +break ; + } + plat->mode = mode;return 0 ;
include/spi.h +4 -0
@@ -23,6 +23,10 @@#define SPI_LOOP 0x20/* loopback mode */ #define SPI_SLAVE 0x40/* slave mode */ #define SPI_PREAMBLE 0x80/* Skip preamble bytes */ +#define SPI_TX_DUAL 0x100/* transmit with 2 wires */ +#define SPI_TX_QUAD 0x200/* transmit with 4 wires */ +#define SPI_RX_DUAL 0x400/* receive with 2 wires */ +#define SPI_RX_QUAD 0x800/* receive with 4 wires */ /* SPI transfer flags */ #define SPI_XFER_BEGIN 0x01/* Assert CS before transfer */
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 5/16 spi: Add support for dual and quad mode
Quoted 6 lines · Mugunthan V N
spi bus can support dual and quad wire data transfers for tx and rx. So defining dual and quad modes for both tx and rx. Also add support to parse bus width used for spi tx and rx transfers.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/b5988dce/attachment.sig>
PATCH v2 5/16 spi: Add support for dual and quad mode
In reply to Mugunthan V NQuoted 24 lines · Mugunthan V N
spi bus can support dual and quad wire data transfers for tx and rx. So defining dual and quad modes for both tx and rx. Also add support to parse bus width used for spi tx and rx transfers.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- drivers/spi/spi-uclass.c | 33 +++++++++++++++++++++++++++++++++ include/spi.h | 4 ++++ 2 files changed, 37 insertions(+)drivers/spi/spi-uclass.c +1
-0@@ -349,6 +349,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, struct dm_spi_slave_platdata *plat) {int mode =0 ; +int value; plat->cs =fdtdec_get_int (blob, node,"reg" ,-1 ); plat->max_hz =fdtdec_get_int (blob, node,"spi-max-frequency" ,0 );
drivers/spi/spi-uclass.c int spi_slave_ofdata_to_platdata(const void *blob, int node, · line 366
Quoted 6 lines
drivers/spi/spi-uclass.c +3
-0@@ -360,6 +361,38 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, mode |=SPI_CS_HIGH ;if (fdtdec_get_bool (blob, node,"spi-half-duplex" )) mode |=SPI_PREAMBLE ; + +/* Device DUAL/QUAD mode */ + value =fdtdec_get_int (blob, node,"spi-tx-bus-width" ,1 );
Value never be negative so better to use fdtdec_get_uint, comments?
Quoted 54 lines
drivers/spi/spi-uclass.c +29
-0+switch (value) { +case 1 : +break ; +case 2 : + mode |=SPI_TX_DUAL ; +break ; +case 4 : + mode |=SPI_TX_QUAD ; +break ; +default : +error ("spi-tx-bus-width %d not supported\n" , value); +break ; + } + + value =fdtdec_get_int (blob, node,"spi-rx-bus-width" ,1 ); +switch (value) { +case 1 : +break ; +case 2 : + mode |=SPI_RX_DUAL ; +break ; +case 4 : + mode |=SPI_RX_QUAD ; +break ; +default : +error ("spi-rx-bus-width %d not supported\n" , value); +break ; + } + plat->mode = mode;return 0 ;include/spi.h +4
-1@@ -23,6 +23,10 @@#define SPI_LOOP 0x20/* loopback mode */ #define SPI_SLAVE 0x40/* slave mode */ #define SPI_PREAMBLE 0x80/* Skip preamble bytes */ +#define SPI_TX_DUAL 0x100/* transmit with 2 wires */ +#define SPI_TX_QUAD 0x200/* transmit with 4 wires */ +#define SPI_RX_DUAL 0x400/* receive with 2 wires */ +#define SPI_RX_QUAD 0x800/* receive with 4 wires */ /* SPI transfer flags */ #define SPI_XFER_BEGIN 0x01/* Assert CS before transfer */ --2.6.2.280.g74301d6
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 1 line
Jagan | openedev.
PATCH v2 6/16 dra7xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
In reply to Mugunthan V NSince spl doesn't support DM currently, do not define DM_SPI and DM_SPI_FLASH for spl build.
--- include/configs/dra7xx_evm.h | 5 +++++ 1 file changed, 5 insertions(+)
include/configs/dra7xx_evm.h +5 -0
@@ -131,6 +131,11 @@#define CONFIG_DEFAULT_SPI_MODE SPI_MODE_3#define CONFIG_QSPI_QUAD_SUPPORT +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_DM_SPI +#undef CONFIG_DM_SPI_FLASH +#endif +/* * Default to using SPI for environment, etc. * 0x000000 - 0x010000 : QSPI.SPL (64KiB)
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 6/16 dra7xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
Hi Mugunthan,
Quoted 2 lines · Mugunthan V N
Since spl doesn't support DM currently, do not define
DM_SPIandDM_SPI_FLASHfor spl build.
Do you mean 'Since OMAP's SPL doesn't support...'?
Quoted 23 lines
Signed-off-by Mugunthan V N <[email protected]>--- include/configs/dra7xx_evm.h | 5 +++++ 1 file changed, 5 insertions(+)include/configs/dra7xx_evm.h +5
-1@@ -131,6 +131,11 @@#define CONFIG_DEFAULT_SPI_MODE SPI_MODE_3#define CONFIG_QSPI_QUAD_SUPPORT +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_DM_SPI +#undef CONFIG_DM_SPI_FLASH +#endif +/* * Default to using SPI for environment, etc. * 0x000000 - 0x010000 : QSPI.SPL (64KiB) --
Quoted 2 lines
2.6.2.280.g74301d6
Regards,
Simon
PATCH v2 6/16 dra7xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
Quoted 7 lines · Simon Glass
Hi Mugunthan,
Quoted 2 lines · Mugunthan V N
Quoted 2 lines
Since spl doesn't support DM currently, do not define
DM_SPIandDM_SPI_FLASHfor spl build.Do you mean 'Since OMAP's SPL doesn't support...'?
Right, for OMAP it is not supported. Will fix it in next version.
Regards
Mugunthan V N
PATCH v2 7/16 dts: dra7: add spi alias for qspi
In reply to Mugunthan V Nadd spi alias for qspi so that spi probes the device and driver successfully.
--- arch/arm/dts/dra7.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/dts/dra7.dtsi +1 -0
@@ -41,6 +41,7 @@ ethernet1 = &cpsw_emac1; d_can0 = &dcan1; d_can1 = &dcan2; + spi0 = &qspi; }; timer {
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 7/16 dts: dra7: add spi alias for qspi
Quoted 14 lines · Mugunthan V N
add spi alias for qspi so that spi probes the device and driver successfully.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 1 + 1 file changed, 1 insertion(+)arch/arm/dts/dra7.dtsi +0
-0
arch/arm/dts/dra7.dtsi line 47
Quoted 7 lines
arch/arm/dts/dra7.dtsi +1
-0@@ -41,6 +41,7 @@ ethernet1 = &cpsw_emac1; d_can0 = &dcan1; d_can1 = &dcan2; + spi0 = &qspi; }; timer {
Is this upstream already?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/8e950815/attachment.sig>
PATCH v2 8/16 drivers: spi: ti_qspi: convert driver to adopt device driver model
In reply to Mugunthan V Nadopt ti_qspi driver to device driver model
--- drivers/spi/ti_qspi.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+)
drivers/spi/ti_qspi.c +172 -0
@@ -11,11 +11,14 @@#include <asm/arch/omap.h> #include <malloc.h> #include <spi.h> +#include <dm.h> #include <asm/gpio.h> #include <asm/omap_gpio.h> #include <asm/omap_common.h> #include <asm/ti-common/ti-edma3.h> +DECLARE_GLOBAL_DATA_PTR ; +/* ti qpsi register bit masks */ #define QSPI_TIMEOUT 2000000#define QSPI_FCLK 192000000
@@ -49,12 +52,14 @@#define CORE_CTRL_IO 0x4a002558#define QSPI_CMD_READ (0x3 << 0) +#define QSPI_CMD_READ_DUAL (0x6b << 0)#define QSPI_CMD_READ_QUAD (0x6b << 0)#define QSPI_CMD_READ_FAST (0x0b << 0)#define QSPI_SETUP0_NUM_A_BYTES (0x2 << 8)#define QSPI_SETUP0_NUM_D_BYTES_NO_BITS (0x0 << 10)#define QSPI_SETUP0_NUM_D_BYTES_8_BITS (0x1 << 10)#define QSPI_SETUP0_READ_NORMAL (0x0 << 12) +#define QSPI_SETUP0_READ_DUAL (0x1 << 12)#define QSPI_SETUP0_READ_QUAD (0x3 << 12)#define QSPI_CMD_WRITE (0x2 << 16)#define QSPI_NUM_DUMMY_BITS (0x0 << 24)
@@ -294,6 +299,8 @@ void spi_flash_copy_mmap(void *data, void *offset, size_t len) }#endif +#ifndef CONFIG_DM_SPI +static inline struct ti_qspi_priv *to_ti_qspi_priv (struct spi_slave *slave) { return container_of(slave, struct ti_qspi_priv, slave);
@@ -407,3 +414,168 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, priv->slave.bus, priv->slave.cs, bitlen, flags);return __ti_qspi_xfer (priv, bitlen, dout, din, flags, priv->slave.cs); } + +#else /* CONFIG_DM_SPI */ + +static void __ti_qspi_setup_memorymap (struct ti_qspi_priv *priv, +struct spi_slave *slave, +bool enable) +{ +u32 memval; +u32 mode = slave->mode & (SPI_RX_QUAD |SPI_RX_DUAL ); + +if (!enable) { +writel (0 , &priv->base->setup0); +return ; + } + + memval =QSPI_SETUP0_NUM_A_BYTES |QSPI_CMD_WRITE |QSPI_NUM_DUMMY_BITS ; + +switch (mode) { +case SPI_RX_QUAD : + memval |=QSPI_CMD_READ_QUAD ; + memval |=QSPI_SETUP0_NUM_D_BYTES_8_BITS ; + memval |=QSPI_SETUP0_READ_QUAD ; + slave->op_mode_rx =SPI_OPM_RX_QOF ; +break ; +case SPI_RX_DUAL : + memval |=QSPI_CMD_READ_DUAL ; + memval |=QSPI_SETUP0_NUM_D_BYTES_8_BITS ; + memval |=QSPI_SETUP0_READ_DUAL ; +break ; +default : + memval |=QSPI_CMD_READ ; + memval |=QSPI_SETUP0_NUM_D_BYTES_NO_BITS ; + memval |=QSPI_SETUP0_READ_NORMAL ; +break ; + } + +writel (memval, &priv->base->setup0); +} + + +static int ti_qspi_set_speed (struct udevice *bus,uint max_hz) +{ +struct ti_qspi_priv *priv =dev_get_priv (bus); + +ti_spi_set_speed (priv, max_hz); + +return 0 ; +} + +static int ti_qspi_set_mode (struct udevice *bus,uint mode) +{ +struct ti_qspi_priv *priv =dev_get_priv (bus); +return __ti_qspi_set_mode (priv, mode); +} + +static int ti_qspi_claim_bus (struct udevice *dev) +{ +struct dm_spi_slave_platdata *slave_plat =dev_get_parent_platdata (dev); +struct spi_slave *slave =dev_get_parent_priv (dev); +struct ti_qspi_priv *priv; +struct udevice *bus; + + bus = dev->parent; + priv =dev_get_priv (bus); + +__ti_qspi_setup_memorymap (priv, slave, true); + +return __ti_qspi_claim_bus (priv, slave_plat->cs); +} + +static int ti_qspi_release_bus (struct udevice *dev) +{ +struct spi_slave *slave =dev_get_parent_priv (dev); +struct ti_qspi_priv *priv; +struct udevice *bus; + + bus = dev->parent; + priv =dev_get_priv (bus); + +__ti_qspi_setup_memorymap (priv, slave, false); +__ti_qspi_release_bus (priv); + +return 0 ; +} + +static int ti_qspi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din,unsigned long flags) +{ +struct dm_spi_slave_platdata *slave =dev_get_parent_platdata (dev); +struct ti_qspi_priv *priv; +struct udevice *bus; + + bus = dev->parent; + priv =dev_get_priv (bus); + +return __ti_qspi_xfer (priv, bitlen, dout, din, flags, slave->cs); +} + +static int ti_qspi_probe (struct udevice *bus) +{ +/* Nothing to do in probe */ +return 0 ; +} + +static int ti_qspi_ofdata_to_platdata (struct udevice *bus) +{ +struct ti_qspi_priv *priv =dev_get_priv (bus); +const void *blob = gd->fdt_blob; +int node = bus->of_offset; +fdt_addr_t addr; + + priv->base = (struct ti_qspi_regs *)dev_get_addr (bus); + priv->slave.memory_map = (void *)dev_get_addr_index (bus,1 ); + addr =dev_get_addr_index (bus,2 ); + priv->ctrl_mod_mmap = (addr ==FDT_ADDR_T_NONE ) ?NULL : (void *)addr; + + priv->slave.max_hz =fdtdec_get_int (blob, node,"spi-max-frequency" , +-1 ); +if (priv->slave.max_hz <0 ) { +debug ("Error: Max frequency missing\n" ); +return -ENODEV ; + } + priv->num_cs =fdtdec_get_int (blob, node,"num-cs" ,4 ); + +debug ("%s: regs=<0x%x>, max-frequency=%d\n" , __func__, + (int )priv->base, priv->slave.max_hz); + +return 0 ; +} + +static int ti_qspi_child_pre_probe (struct udevice *dev) +{ +struct spi_slave *slave =dev_get_parent_priv (dev); +struct udevice *bus =dev_get_parent (dev); +struct ti_qspi_priv *priv =dev_get_priv (bus); + + slave->memory_map = priv->slave.memory_map; +return 0 ; +} + +static const struct dm_spi_ops ti_qspi_ops = { + .claim_bus = ti_qspi_claim_bus, + .release_bus = ti_qspi_release_bus, + .xfer = ti_qspi_xfer, + .set_speed = ti_qspi_set_speed, + .set_mode = ti_qspi_set_mode, +}; + +static const struct udevice_id ti_qspi_ids[] = { + { .compatible ="ti,dra7xxx-qspi" }, + { .compatible ="ti,am4372-qspi" }, + { } +}; + +U_BOOT_DRIVER (ti_qspi) = { + .name ="ti_qspi" , + .id =UCLASS_SPI , + .of_match = ti_qspi_ids, + .ops = &ti_qspi_ops, + .ofdata_to_platdata = ti_qspi_ofdata_to_platdata, + .priv_auto_alloc_size =sizeof (struct ti_qspi_priv ), + .probe = ti_qspi_probe, + .child_pre_probe = ti_qspi_child_pre_probe, +}; +#endif /* CONFIG_DM_SPI */
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 8/16 drivers: spi: ti_qspi: convert driver to adopt device driver model
Quoted 6 lines · Mugunthan V N
adopt
ti_qspidriver to device driver modelSigned-off-by Mugunthan V N <[email protected]>--- drivers/spi/ti_qspi.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+)
PATCH v2 8/16 drivers: spi: ti_qspi: convert driver to adopt device driver model
In reply to Mugunthan V NQuoted 3 lines · Mugunthan V N
adopt
ti_qspidriver to device driver modelSigned-off-by Mugunthan V N <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/46fc855f/attachment.sig>
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
In reply to Mugunthan V NAdd qspi memory map and control module register maps to device tree.
--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/dts/dra7.dtsi +2 -2
@@ -1104,8 +1104,8 @@ qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
Quoted 13 lines · Mugunthan V N
Add qspi memory map and control module register maps to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/dts/dra7.dtsi +0
-0
arch/arm/dts/dra7.dtsi line 1111
Quoted 10 lines
arch/arm/dts/dra7.dtsi +2
-2@@ -1104,8 +1104,8 @@ qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";
Is this already upstream?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/b39c0fe0/attachment.sig>
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
Quoted 16 lines · Tom Rini
Quoted 14 lines · Mugunthan V N
Add qspi memory map and control module register maps to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/dts/dra7.dtsi +0
-0@@ -1104,8 +1104,8 @@
Quoted 12 lines
arch/arm/dts/dra7.dtsi line 1111
Quoted 9 lines
arch/arm/dts/dra7.dtsi +2
-2qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";Is this already upstream?
The documentation part is already upstreamed. Driver in kernel doesn't support mmap mode yet so dt changes are not present. Vignesh has submitted the mmap patches [1] and is under review.
[1]: https://lkml.org/lkml/2015/11/10/14
Regards
Mugunthan V N
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
Quoted 30 lines · Mugunthan V N
Quoted 16 lines · Tom Rini
Quoted 14 lines · Mugunthan V N
Add qspi memory map and control module register maps to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/dts/dra7.dtsi +0
-0@@ -1104,8 +1104,8 @@Quoted 12 lines
arch/arm/dts/dra7.dtsi line 1111
Quoted 9 lines
arch/arm/dts/dra7.dtsi +2
-2qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";Is this already upstream?
Quoted 5 lines
The documentation part is already upstreamed. Driver in kernel doesn't support mmap mode yet so dt changes are not present. Vignesh has submitted the mmap patches [1] and is under review.
OK, and we can't even get the reg names part in the DT upstream until then?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151112/169f0c76/attachment.sig>
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
Quoted 31 lines · Tom Rini
Quoted 30 lines · Mugunthan V N
Quoted 28 lines · Tom Rini
Quoted 13 lines · Mugunthan V N
Add qspi memory map and control module register maps to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/dts/dra7.dtsi +0
-0arch/arm/dts/dra7.dtsi line 1111
Quoted 10 lines
arch/arm/dts/dra7.dtsi +2
-2@@ -1104,8 +1104,8 @@ qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";Is this already upstream?
Quoted 9 lines
Quoted 5 lines
The documentation part is already upstreamed. Driver in kernel doesn't support mmap mode yet so dt changes are not present. Vignesh has submitted the mmap patches [1] and is under review.
OK, and we can't even get the reg names part in the DT upstream until then?
I don't think we can get reg names in the DT upstream separately. But there shouldn't be any issues as there is documentation already present in kernel and submitted kernel patch DT nodes are similar to what I have submitted.
Regards
Mugunthan V N
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
Quoted 38 lines · Mugunthan V N
Quoted 37 lines · Tom Rini
Quoted 35 lines · Mugunthan V N
Quoted 16 lines · Tom Rini
Quoted 14 lines · Mugunthan V N
Add qspi memory map and control module register maps to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/dts/dra7.dtsi +0
-0@@ -1104,8 +1104,8 @@Quoted 12 lines
arch/arm/dts/dra7.dtsi line 1111
Quoted 9 lines
arch/arm/dts/dra7.dtsi +2
-2qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";Is this already upstream?
The documentation part is already upstreamed. Driver in kernel doesn't support mmap mode yet so dt changes are not present. Vignesh has submitted the mmap patches [1] and is under review.
Quoted 8 lines
Quoted 3 lines
OK, and we can't even get the reg names part in the DT upstream until then?
I don't think we can get reg names in the DT upstream separately. But there shouldn't be any issues as there is documentation already present in kernel and submitted kernel patch DT nodes are similar to what I have submitted.
Similar or the same? We'll be dropping in (and quick diff'ing) a new DT from the kernel at some point in the future. So if there's chance of things changing, we want to wait.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151115/55a2c560/attachment.sig>
PATCH v2 9/16 arm: dts: dra7: add qspi register maps for memory map and control module
Quoted 43 lines · Tom Rini
Quoted 42 lines · Mugunthan V N
Quoted 40 lines · Tom Rini
Quoted 30 lines · Mugunthan V N
Quoted 16 lines · Tom Rini
Quoted 14 lines · Mugunthan V N
Add qspi memory map and control module register maps to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/dra7.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/dts/dra7.dtsi +0
-0@@ -1104,8 +1104,8 @@Quoted 12 lines
arch/arm/dts/dra7.dtsi line 1111
Quoted 9 lines
arch/arm/dts/dra7.dtsi +2
-2qspi: qspi at 4b300000 { compatible = "ti,dra7xxx-qspi"; - reg = <0x4b300000 0x100>; - reg-names = "qspi_base"; + reg = <0x4b300000 0x100>, <0x5c000000 0x4000000>, <0x4a002558 0x4>; + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";Is this already upstream?
Quoted 5 lines
The documentation part is already upstreamed. Driver in kernel doesn't support mmap mode yet so dt changes are not present. Vignesh has submitted the mmap patches [1] and is under review.
OK, and we can't even get the reg names part in the DT upstream until then?
Quoted 9 lines
Quoted 4 lines
I don't think we can get reg names in the DT upstream separately. But there shouldn't be any issues as there is documentation already present in kernel and submitted kernel patch DT nodes are similar to what I have submitted.
Similar or the same? We'll be dropping in (and quick diff'ing) a new DT from the kernel at some point in the future. So if there's chance of things changing, we want to wait.
Its Similar now, will make it Same in next version
Regards
Mugunthan V N
PATCH v2 10/16 drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
In reply to Mugunthan V NAdd compatible for spansion 32MiB spi flash s25fl256s1.
--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +1 -0
@@ -502,6 +502,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, + { .compatible ="s25fl256s1" }, { } };
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 10/16 drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
Hi Mugunthan,
Quoted 12 lines · Mugunthan V N
Add compatible for spansion 32MiB spi flash s25fl256s1.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/spi/sf_probe.c +0
-0
drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 505
Quoted 4 lines
drivers/mtd/spi/sf_probe.c +1
-0@@ -502,6 +502,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, + { .compatible ="s25fl256s1" },
Instead, is it possible to add "spi-flash" to the list of compatible strings in your device tree?
Quoted 6 lines
drivers/mtd/spi/sf_probe.c +0
-1{ } }; --2.6.2.280.g74301d6
Regards,
Simon
PATCH v2 10/16 drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
Quoted 16 lines · Simon Glass
Hi Mugunthan,
Quoted 13 lines · Mugunthan V N
Add compatible for spansion 32MiB spi flash s25fl256s1.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/spi/sf_probe.c +0
-0@@ -502,6 +502,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {
Quoted 7 lines
drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 505
Quoted 3 lines
drivers/mtd/spi/sf_probe.c +1
-0static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, + { .compatible ="s25fl256s1" },Instead, is it possible to add "spi-flash" to the list of compatible strings in your device tree?
The compatible "spi-flash" is not defined/documented in kernel and compatible "s25fl256s1" is already documented and present in dt files. So it will be good to follow the same dt compatibles in U-Boot so that future merge/sync will be easier.
Regards
Mugunthan V N
PATCH v2 10/16 drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
Quoted 25 lines · Mugunthan V N
Quoted 16 lines · Simon Glass
Hi Mugunthan,
Quoted 13 lines · Mugunthan V N
Add compatible for spansion 32MiB spi flash s25fl256s1.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/spi/sf_probe.c +0
-0@@ -502,6 +502,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {Quoted 7 lines
drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 505
Quoted 3 lines
drivers/mtd/spi/sf_probe.c +1
-0static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, + { .compatible ="s25fl256s1" },Instead, is it possible to add "spi-flash" to the list of compatible strings in your device tree?
Quoted 4 lines
The compatible "spi-flash" is not defined/documented in kernel and compatible "s25fl256s1" is already documented and present in dt files. So it will be good to follow the same dt compatibles in U-Boot so that future merge/sync will be easier.
Agreed.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151112/6c09688d/attachment.sig>
PATCH v2 10/16 drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
Hi,
Quoted 26 lines · Tom Rini
Quoted 25 lines · Mugunthan V N
Quoted 23 lines · Simon Glass
Hi Mugunthan,
Quoted 12 lines · Mugunthan V N
Add compatible for spansion 32MiB spi flash s25fl256s1.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/spi/sf_probe.c +0
-0drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 505
Quoted 4 lines
drivers/mtd/spi/sf_probe.c +1
-0@@ -502,6 +502,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, + { .compatible ="s25fl256s1" },Instead, is it possible to add "spi-flash" to the list of compatible strings in your device tree?
Quoted 6 lines
Quoted 4 lines
The compatible "spi-flash" is not defined/documented in kernel and compatible "s25fl256s1" is already documented and present in dt files. So it will be good to follow the same dt compatibles in U-Boot so that future merge/sync will be easier.
Agreed.
I see this in kernel upstream at present:
git grep s25fl256s1
arch/arm/boot/dts/dra7-evm.dts: compatible = "s25fl256s1";
arch/arm/boot/dts/dra72-evm.dts: compatible = "s25fl256s1";
arch/arm/boot/dts/qcom-ipq8064-ap148.dts:
compatible = "s25fl256s1";arch/powerpc/boot/dts/fsl/kmcoge4.dts:
compatible = "spansion,s25fl256s1";drivers/mtd/devices/m25p80.c: {"s25fl256s1"}, {"s25fl512s"},
{"s25sl12801"}, {"s25fl008k"},drivers/mtd/devices/st_spi_fsm.c: { "s25fl256s1", 0x010219,0x4d01, 64 * 1024, 512,drivers/mtd/spi-nor/spi-nor.c: { "s25fl256s1", INFO(0x010219, 0x4d01,
64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
There seems to be some confusion as to whether to include "spansion" or not. I feel it should be included.
The problem is that in U-Boot at present this compatible string does not affect any behaviour. We still scan the chip to figure out its type from its ID. Do you want to add a .data value for it, and skip the probing, or are you just trying to trigger the driver to bind?
Regards,
Simon
PATCH v2 10/16 drivers: mtd: spi: sf_probe: add compatible for spansion spi flash
Quoted 52 lines · Simon Glass
Hi,
Quoted 26 lines · Tom Rini
Quoted 25 lines · Mugunthan V N
Quoted 23 lines · Simon Glass
Hi Mugunthan,
Quoted 12 lines · Mugunthan V N
Add compatible for spansion 32MiB spi flash s25fl256s1.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/spi/sf_probe.c +0
-0drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 505
Quoted 4 lines
drivers/mtd/spi/sf_probe.c +1
-0@@ -502,6 +502,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, + { .compatible ="s25fl256s1" },Instead, is it possible to add "spi-flash" to the list of compatible strings in your device tree?
Quoted 6 lines
Quoted 4 lines
The compatible "spi-flash" is not defined/documented in kernel and compatible "s25fl256s1" is already documented and present in dt files. So it will be good to follow the same dt compatibles in U-Boot so that future merge/sync will be easier.
Agreed.
I see this in kernel upstream at present:
git grep s25fl256s1
arch/arm/boot/dts/dra7-evm.dts: compatible = "s25fl256s1"; arch/arm/boot/dts/dra72-evm.dts: compatible = "s25fl256s1"; arch/arm/boot/dts/qcom-ipq8064-ap148.dts: compatible = "s25fl256s1";
arch/powerpc/boot/dts/fsl/kmcoge4.dts:
compatible = "spansion,s25fl256s1";drivers/mtd/devices/m25p80.c: {"s25fl256s1"}, {"s25fl512s"},
{"s25sl12801"}, {"s25fl008k"},drivers/mtd/devices/st_spi_fsm.c: { "s25fl256s1",0x010219,0x4d01, 64 * 1024, 512,drivers/mtd/spi-nor/spi-nor.c: { "s25fl256s1", INFO(0x010219,0x4d01,
64 * 1024, 512,SPI_NOR_DUAL_READ|SPI_NOR_QUAD_READ) },
Quoted 8 lines
There seems to be some confusion as to whether to include "spansion" or not. I feel it should be included.
The problem is that in U-Boot at present this compatible string does not affect any behaviour. We still scan the chip to figure out its type from its ID. Do you want to add a .data value for it, and skip the probing, or are you just trying to trigger the driver to bind?
These compatibles are just used to bind the driver as spi-flash compatible is not present/documented in Kernel.
Regards
Mugunthan V N
PATCH v2 11/16 drivers: mtd: spi: sf_probe: add compatible for Macronix spi flash
In reply to Mugunthan V NAdd compatible for Macronix 64MiB spi flash mx66l51235l.
--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +1 -0
@@ -503,6 +503,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, { .compatible ="s25fl256s1" }, + { .compatible ="mx66l51235l" }, { } };
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 11/16 drivers: mtd: spi: sf_probe: add compatible for Macronix spi flash
Hi Mugunthan,
Quoted 12 lines · Mugunthan V N
Add compatible for Macronix 64MiB spi flash mx66l51235l.
Signed-off-by Mugunthan V N <[email protected]>--- drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/spi/sf_probe.c +0
-0
drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 506
Quoted 4 lines
drivers/mtd/spi/sf_probe.c +1
-0@@ -503,6 +503,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {static const struct udevice_id spi_flash_std_ids[] = { { .compatible ="spi-flash" }, { .compatible ="s25fl256s1" }, + { .compatible ="mx66l51235l" },
Can you add "spi-flash" to your device tree file instead?
Quoted 6 lines
drivers/mtd/spi/sf_probe.c +0
-1{ } }; --2.6.2.280.g74301d6
Regards,
Simon
PATCH v2 12/16 defconfig: dra72_evm: enable spi driver model
In reply to Mugunthan V Nenable mmc driver model for dra72_evm as ti_qspi supports driver model
--- configs/dra72_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/dra72_evm_defconfig +2 -0
@@ -16,3 +16,5 @@ CONFIG_OF_CONTROL=y CONFIG_DM=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y +CONFIG_DM_SPI=y +CONFIG_DM_SPI_FLASH=y
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 12/16 defconfig: dra72_evm: enable spi driver model
Quoted 5 lines · Mugunthan V N
enable mmc driver model for
dra72_evmasti_qspisupports driver modelSigned-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/cd42b925/attachment.sig>
PATCH v2 13/16 defconfig: dra74_evm: enable spi driver model
In reply to Mugunthan V Nenable mmc driver model for dra74_evm as ti_qspi supports driver model
--- configs/dra74_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/dra74_evm_defconfig +2 -0
@@ -15,3 +15,5 @@ CONFIG_DM=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y CONFIG_DM_GPIO=y +CONFIG_DM_SPI=y +CONFIG_DM_SPI_FLASH=y
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 13/16 defconfig: dra74_evm: enable spi driver model
Quoted 5 lines · Mugunthan V N
enable mmc driver model for
dra74_evmasti_qspisupports driver modelSigned-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/27ec898f/attachment.sig>
PATCH v2 14/16 am43xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
In reply to Mugunthan V NSince spl doesn't support DM currently, do not define DM_SPI and DM_SPI_FLASH for spl build.
--- include/configs/am43xx_evm.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/am43xx_evm.h +2 -0
@@ -146,6 +146,8 @@*/ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_SPI +#undef CONFIG_DM_SPI_FLASH#endif #ifndef CONFIG_SPL_BUILD
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 14/16 am43xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
Hi Mugunthan,
Quoted 2 lines · Mugunthan V N
Since spl doesn't support DM currently, do not define
DM_SPIandDM_SPI_FLASHfor spl build.
Since spl doesn't support DM currently on OMAP?
It is supported in general, right?
Quoted 20 lines
Signed-off-by Mugunthan V N <[email protected]>--- include/configs/am43xx_evm.h | 2 ++ 1 file changed, 2 insertions(+)include/configs/am43xx_evm.h +2
-1@@ -146,6 +146,8 @@*/ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_SPI +#undef CONFIG_DM_SPI_FLASH#endif #ifndef CONFIG_SPL_BUILD --
Quoted 2 lines
2.6.2.280.g74301d6
Regards,
Simon
PATCH v2 14/16 am43xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl
Quoted 9 lines · Simon Glass
Hi Mugunthan,
Quoted 2 lines · Mugunthan V N
Quoted 2 lines
Since spl doesn't support DM currently, do not define
DM_SPIandDM_SPI_FLASHfor spl build.Since spl doesn't support DM currently on OMAP?
It is supported in general, right?
Right, it is supported in general only for OMAP it is not supported. Will fix it in next version.
Regards
Mugunthan V N
PATCH v2 15/16 arm: dts: am4372: add qspi register maps for memory map
In reply to Mugunthan V NAdd qspi memory map address to device tree.
--- arch/arm/dts/am4372.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/dts/am4372.dtsi +3 -1
@@ -25,6 +25,7 @@ serial0 = &uart0; ethernet0 = &cpsw_emac0; ethernet1 = &cpsw_emac1; + spi0 = &qspi; }; cpus {
@@ -902,7 +903,8 @@ qspi: qspi at 47900000 { compatible = "ti,am4372-qspi"; - reg = <0x47900000 0x100>; + reg = <0x47900000 0x100>, <0x30000000 0x4000000>; + reg-names = "qspi_base", "qspi_mmap"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 15/16 arm: dts: am4372: add qspi register maps for memory map
Quoted 21 lines · Mugunthan V N
Add qspi memory map address to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/am4372.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm/dts/am4372.dtsi +1
-0@@ -25,6 +25,7 @@ serial0 = &uart0; ethernet0 = &cpsw_emac0; ethernet1 = &cpsw_emac1; + spi0 = &qspi; }; cpus {
arch/arm/dts/am4372.dtsi line 910
Quoted 9 lines
arch/arm/dts/am4372.dtsi +2
-1@@ -902,7 +903,8 @@ qspi: qspi at 47900000 { compatible = "ti,am4372-qspi"; - reg = <0x47900000 0x100>; + reg = <0x47900000 0x100>, <0x30000000 0x4000000>; + reg-names = "qspi_base", "qspi_mmap"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";
Is this upstream already?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/b00465c4/attachment.sig>
PATCH v2 15/16 arm: dts: am4372: add qspi register maps for memory map
Quoted 23 lines · Tom Rini
Quoted 22 lines · Mugunthan V N
Add qspi memory map address to device tree.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/arm/dts/am4372.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm/dts/am4372.dtsi +1
-0@@ -25,6 +25,7 @@ serial0 = &uart0; ethernet0 = &cpsw_emac0; ethernet1 = &cpsw_emac1; + spi0 = &qspi; }; cpus {@@ -902,7 +903,8 @@
Quoted 11 lines
arch/arm/dts/am4372.dtsi line 910
Quoted 8 lines
arch/arm/dts/am4372.dtsi +2
-1qspi: qspi at 47900000 { compatible = "ti,am4372-qspi"; - reg = <0x47900000 0x100>; + reg = <0x47900000 0x100>, <0x30000000 0x4000000>; + reg-names = "qspi_base", "qspi_mmap"; #address-cells = <1>; #size-cells = <0>; ti,hwmods = "qspi";Is this upstream already?
The documentation part is already upstreamed. Driver in kernel doesn't support mmap mode yet, so dt changes are not present. Vignesh has submitted the mmap patches [1] and is under review.
[1]: https://lkml.org/lkml/2015/11/10/14
Regards
Mugunthan V N
PATCH v2 16/16 defconfig: am437x_sk_evm: enable spi driver model
In reply to Mugunthan V Nenable mmc driver model for am437x_sk_evm as ti_qspi supports driver model
--- configs/am437x_sk_evm_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/am437x_sk_evm_defconfig +3 -0
@@ -15,3 +15,6 @@ CONFIG_SPI_FLASH=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y CONFIG_DM_MMC=y +CONFIG_DM_SPI=y +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_BAR=y
Signature · 1 line
2.6.2.280.g74301d6
PATCH v2 16/16 defconfig: am437x_sk_evm: enable spi driver model
Quoted 5 lines · Mugunthan V N
enable mmc driver model for
am437x_sk_evmasti_qspisupports driver modelSigned-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/0ff36987/attachment.sig>
PATCH v2 16/16 defconfig: am437x_sk_evm: enable spi driver model
In reply to Mugunthan V NQuoted 1 line · Mugunthan V N
enable mmc driver model for
am437x_sk_evmasti_qspisupports
typo its should be spi not mmc.
Quoted 26 lines
driver model
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Simon Glass <[email protected]>--- configs/am437x_sk_evm_defconfig | 3 +++ 1 file changed, 3 insertions(+)configs/am437x_sk_evm_defconfig +3
-1@@ -15,3 +15,6 @@ CONFIG_SPI_FLASH=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y CONFIG_DM_MMC=y +CONFIG_DM_SPI=y +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_BAR=y --2.6.2.280.g74301d6
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 1 line
Jagan | openedev.