kirkwood spi_claim/release_bus support
Subsystems (2)
v3 cover kirkwood spi_claim/release_bus support
This series adds generic support for the spi_claim/release_bus functions for the kirkwood processors.
The implementation was already discussed in another thread following my first board specific submission of the patch.
The series adds two functions to the kirkwood mpp code to be able to temporarily save and then restore the mpp configuration.
Changes for v2:
- save MPP configuration with mpp_read function as dicussed on ML
- moved CS pin MPP config to spi_setup_slave only
- add backup fo CS pin in spi_setup_slave and reset in spi_free_slave
Changes for v3:
- moved mpp_read function functionality into mpp_conf function
- fixed all calls to mpp_conf so that they are compliant with the newly necessary mpp_conf prototype
Valentin Longchamp (5):
kirkwood: add save functionality kirkwood_mpp_conf function
kirkwood: fix calls to kirkwood_mpp_conf
kw_spi: backup and reset the MPP of the chosen CS pin
kw_spi: support spi_claim/release_bus functions
kw_spi: add weak functions board_spi_claim/release_bus
arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 14 ++++- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- arch/arm/include/asm/arch-kirkwood/spi.h | 11 ++++ board/LaCie/net2big_v2/net2big_v2.c | 2 +- board/LaCie/netspace_v2/netspace_v2.c | 2 +- board/Marvell/dreamplug/dreamplug.c | 2 +- board/Marvell/guruplug/guruplug.c | 2 +- board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c | 2 +- board/Marvell/openrd/openrd.c | 2 +- board/Marvell/rd6281a/rd6281a.c | 2 +- board/Marvell/sheevaplug/sheevaplug.c | 2 +- board/Seagate/dockstar/dockstar.c | 2 +- board/cloudengines/pogo_e02/pogo_e02.c | 2 +- board/d-link/dns325/dns325.c | 2 +- board/keymile/km_arm/km_arm.c | 6 +- board/raidsonic/ib62x0/ib62x0.c | 2 +- drivers/spi/kirkwood_spi.c | 64 +++++++++++++++++++---- 17 files changed, 93 insertions(+), 28 deletions(-)
PATCH v3 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
If a second non NULL argument is given to the kirkwood_mpp_conf function, it will be used to store the current configuration of the MPP registers. mpp_save must be a preallocated table of the same size as mpp_list and it must be zero terminated as well.
A later call to kirkwood_mpp_conf function with this saved list as first (mpp_conf) argment will set the configuration back.
--- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 14 ++++++++++++-- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +12 -2
@@ -31,11 +31,11 @@ static u32 kirkwood_variant(void)#define MPP_CTRL (i) (KW_MPP_BASE + (i* 4))#define MPP_NR_REGS (1 + MPP_MAX/8) -void kirkwood_mpp_conf (u32 *mpp_list) +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save) {u32 mpp_ctrl[MPP_NR_REGS ];unsigned int variant_mask; -int i; +int i, save =0 ; variant_mask =kirkwood_variant ();if (!variant_mask)
@@ -48,10 +48,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) }debug ("\n" ); +if (mpp_save) + save =1 ;while (*mpp_list) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int sel_save;int shift;if (num >MPP_MAX ) {
@@ -66,6 +69,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) } shift = (num &7 ) <<2 ; + +if (save) { + sel_save = (mpp_ctrl[num /8 ] >> shift) &0xf ; + *mpp_save = num | (sel_save <<8 ) | variant_mask; + mpp_save++; + } + mpp_ctrl[num /8 ] &= ~(0xf << shift); mpp_ctrl[num /8 ] |= sel << shift;
arch/arm/include/asm/arch-kirkwood/mpp.h +1 -1
@@ -312,6 +312,6 @@#define MPP_MAX 49 -void kirkwood_mpp_conf (unsigned int *mpp_list); +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save);#endif
Signature · 1 line
1.7.1
PATCH v3 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
Hi Valentin,
Quoted 49 lines · Valentin Longchamp
If a second non NULL argument is given to the
kirkwood_mpp_conffunction, it will be used to store the current configuration of the MPP registers.mpp_savemust be a preallocated table of the same size asmpp_listand it must be zero terminated as well.A later call to
kirkwood_mpp_conffunction with this saved list as first (mpp_conf) argment will set the configuration back.Signed-off-by Valentin Longchamp <[email protected]>cc Holger Brunck <[email protected]>cc Prafulla Wadaskar <[email protected]>--- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 14 ++++++++++++-- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-)arch/arm/cpu/arm926ejs/kirkwood/mpp.c +5
-2@@ -31,11 +31,11 @@ static u32 kirkwood_variant(void)#define MPP_CTRL (i) (KW_MPP_BASE + (i* 4))#define MPP_NR_REGS (1 + MPP_MAX/8) -void kirkwood_mpp_conf (u32 *mpp_list) +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save) {u32 mpp_ctrl[MPP_NR_REGS ];unsigned int variant_mask; -int i; +int i, save =0 ; variant_mask =kirkwood_variant ();if (!variant_mask)@@ -48,10 +48,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) }debug ("\n" ); +if (mpp_save) + save =1 ;while (*mpp_list) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int sel_save;int shift;if (num >MPP_MAX ) {
arch/arm/cpu/arm926ejs/kirkwood/mpp.c void kirkwood_mpp_conf(u32 *mpp_list) · line 73
Quoted 5 lines
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +2
-0@@ -66,6 +69,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) } shift = (num &7 ) <<2 ; + +if (save) {
Why using new variable if it's only used in one place? Why not use this here:
if (mpp_save) {Then we don't need save variable at all.
Luka
PATCH v3 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
Hi Luka,
Quoted 61 lines · Luka Perkov
Hi Valentin,
Quoted 49 lines · Valentin Longchamp
If a second non NULL argument is given to the
kirkwood_mpp_conffunction, it will be used to store the current configuration of the MPP registers.mpp_savemust be a preallocated table of the same size asmpp_listand it must be zero terminated as well.A later call to
kirkwood_mpp_conffunction with this saved list as first (mpp_conf) argment will set the configuration back.Signed-off-by Valentin Longchamp <[email protected]>cc Holger Brunck <[email protected]>cc Prafulla Wadaskar <[email protected]>--- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 14 ++++++++++++-- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-)arch/arm/cpu/arm926ejs/kirkwood/mpp.c +5
-2@@ -31,11 +31,11 @@ static u32 kirkwood_variant(void)#define MPP_CTRL (i) (KW_MPP_BASE + (i* 4))#define MPP_NR_REGS (1 + MPP_MAX/8) -void kirkwood_mpp_conf (u32 *mpp_list) +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save) {u32 mpp_ctrl[MPP_NR_REGS ];unsigned int variant_mask; -int i; +int i, save =0 ; variant_mask =kirkwood_variant ();if (!variant_mask)@@ -48,10 +48,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) }debug ("\n" ); +if (mpp_save) + save =1 ;while (*mpp_list) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int sel_save;int shift;if (num >MPP_MAX ) {arch/arm/cpu/arm926ejs/kirkwood/mpp.c void kirkwood_mpp_conf(u32 *mpp_list) · line 73
Quoted 5 lines
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +2
-0@@ -66,6 +69,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) } shift = (num &7 ) <<2 ; + +if (save) {Why using new variable if it's only used in one place? Why not use this here:
Quoted 4 lines
if (mpp_save) {Then we don't need save variable at all.
Yeah you are right, I can directly test on mpp_save, since it should remain NULL during the whole while loop if NULL at the beginning.
PATCH v3 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
Quoted 79 lines
-----Original Message-----
From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
Sent: 01 June 2012 12:33
To: uboot at lukaperkov.net
Cc: Prafulla Wadaskar; Brunck, Holger; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH v3 1/5] kirkwood: add save functionalitykirkwood_mpp_conffunctionHi Luka,
Quoted 5 lines · Luka Perkov
Hi Valentin,
Quoted 2 lines · Valentin Longchamp
If a second non NULL argument is given to the
kirkwood_mpp_conffunction, it will be used to store the current configuration of theMPP
Quoted 1 line
Quoted 1 line
registers.
mpp_savemust be a preallocated table of the same sizeas
Quoted 3 lines
Quoted 3 lines
mpp_listand it must be zero terminated as well.A later call to
kirkwood_mpp_conffunction with this saved list asfirst
Quoted 11 lines
Review
Quoted 11 lines
(
mpp_conf) argment will set the configuration back.Signed-off-by Valentin Longchamp <[email protected]>cc Holger Brunck <[email protected]>cc Prafulla Wadaskar <[email protected]>--- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 14 ++++++++++++-- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/arch/arm/cpu/arm926ejs/kirkwood/mpp.cQuoted 34 lines
Quoted 34 lines
index 3da6c98..158ea84 100644
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +5
-2@@ -31,11 +31,11 @@ static u32 kirkwood_variant(void)#define MPP_CTRL (i) (KW_MPP_BASE + (i* 4))#define MPP_NR_REGS (1 + MPP_MAX/8) -void kirkwood_mpp_conf (u32 *mpp_list) +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save) {u32 mpp_ctrl[MPP_NR_REGS ];unsigned int variant_mask; -int i; +int i, save =0 ; variant_mask =kirkwood_variant ();if (!variant_mask)@@ -48,10 +48,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) }debug ("\n" ); +if (mpp_save) + save =1 ;while (*mpp_list) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int sel_save;int shift;if (num >MPP_MAX ) {@@ -66,6 +69,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) }Quoted 5 lines
arch/arm/cpu/arm926ejs/kirkwood/mpp.c void kirkwood_mpp_conf(u32 *mpp_list) · line 73
Quoted 3 lines
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +2
-0shift = (num &7 ) <<2 ; + +if (save) {Why using new variable if it's only used in one place? Why not use
this
Quoted 2 lines
here:
Quoted 8 lines
Quoted 4 lines
if (mpp_save) {Then we don't need save variable at all.
Yeah you are right, I can directly test on
mpp_save, since it should remain NULL
during the whole while loop if NULL at the beginning.
Pls port v4 with this fix, rest of the patch series looks okay to me.
Regards..
Prafulla . . .
PATCH v4 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
If a second non NULL argument is given to the kirkwood_mpp_conf function, it will be used to store the current configuration of the MPP registers. mpp_save must be a preallocated table of the same size as mpp_list and it must be zero terminated as well.
A later call to kirkwood_mpp_conf function with this saved list as first (mpp_conf) argment will set the configuration back.
--- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 10 +++++++++- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +9 -1
@@ -31,7 +31,7 @@ static u32 kirkwood_variant(void)#define MPP_CTRL (i) (KW_MPP_BASE + (i* 4))#define MPP_NR_REGS (1 + MPP_MAX/8) -void kirkwood_mpp_conf (u32 *mpp_list) +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save) {u32 mpp_ctrl[MPP_NR_REGS ];unsigned int variant_mask;
@@ -52,6 +52,7 @@ void kirkwood_mpp_conf(u32 *mpp_list)while (*mpp_list) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int sel_save;int shift;if (num >MPP_MAX ) {
@@ -66,6 +67,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) } shift = (num &7 ) <<2 ; + +if (mpp_save) { + sel_save = (mpp_ctrl[num /8 ] >> shift) &0xf ; + *mpp_save = num | (sel_save <<8 ) | variant_mask; + mpp_save++; + } + mpp_ctrl[num /8 ] &= ~(0xf << shift); mpp_ctrl[num /8 ] |= sel << shift;
arch/arm/include/asm/arch-kirkwood/mpp.h +1 -1
@@ -312,6 +312,6 @@#define MPP_MAX 49 -void kirkwood_mpp_conf (unsigned int *mpp_list); +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save);#endif
Signature · 1 line
1.7.1
PATCH v4 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
Quoted 16 lines
-----Original Message-----
From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
Sent: 01 June 2012 14:33
Cc: u-boot at lists.denx.de; Valentin Longchamp; Holger Brunck; Prafulla Wadaskar
Subject: [PATCH v4 1/5] kirkwood: add save functionalitykirkwood_mpp_conffunctionIf a second non NULL argument is given to the
kirkwood_mpp_conffunction, it will be used to store the current configuration of the MPP
registers.mpp_savemust be a preallocated table of the same size asmpp_listand it must be zero terminated as well.
Quoted 8 lines
A later call to
kirkwood_mpp_conffunction with this saved list as first
(mpp_conf) argment will set the configuration back.Signed-off-by Valentin Longchamp <[email protected]>cc Holger Brunck <[email protected]>cc Prafulla Wadaskar <[email protected]>---
Have you send just one file? I have received only one!! No Change log, pls send all files with V4 in the patch series.
Regards..
Prafulla . . .
v4 cover kirkwood spi_claim/release_bus support
In reply to Prafulla WadaskarThis series adds generic support for the spi_claim/release_bus functions for the kirkwood processors.
The implementation was already discussed in another thread following my first board specific submission of the patch.
The series adds two functions to the kirkwood mpp code to be able to temporarily save and then restore the mpp configuration.
Changes for v2:
- save MPP configuration with mpp_read function as dicussed on ML
- moved CS pin MPP config to spi_setup_slave only
- add backup fo CS pin in spi_setup_slave and reset in spi_free_slave
Changes for v3:
- moved mpp_read function functionality into mpp_conf function
- fixed all calls to mpp_conf so that they are compliant with the newly necessary mpp_conf prototype
Changes for v4:
- minor fix in the mpp_conf function
Valentin Longchamp (5):
kirkwood: add save functionality kirkwood_mpp_conf function
kirkwood: fix calls to kirkwood_mpp_conf
kw_spi: backup and reset the MPP of the chosen CS pin
kw_spi: support spi_claim/release_bus functions
kw_spi: add weak functions board_spi_claim/release_bus
arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 10 +++- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- arch/arm/include/asm/arch-kirkwood/spi.h | 11 ++++ board/LaCie/net2big_v2/net2big_v2.c | 2 +- board/LaCie/netspace_v2/netspace_v2.c | 2 +- board/Marvell/dreamplug/dreamplug.c | 2 +- board/Marvell/guruplug/guruplug.c | 2 +- board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c | 2 +- board/Marvell/openrd/openrd.c | 2 +- board/Marvell/rd6281a/rd6281a.c | 2 +- board/Marvell/sheevaplug/sheevaplug.c | 2 +- board/Seagate/dockstar/dockstar.c | 2 +- board/cloudengines/pogo_e02/pogo_e02.c | 2 +- board/d-link/dns325/dns325.c | 2 +- board/keymile/km_arm/km_arm.c | 6 +- board/raidsonic/ib62x0/ib62x0.c | 2 +- drivers/spi/kirkwood_spi.c | 64 +++++++++++++++++++---- 17 files changed, 90 insertions(+), 27 deletions(-)
PATCH v4 1/5 kirkwood: add save functionality kirkwood_mpp_conf function
If a second non NULL argument is given to the kirkwood_mpp_conf function, it will be used to store the current configuration of the MPP registers. mpp_save must be a preallocated table of the same size as mpp_list and it must be zero terminated as well.
A later call to kirkwood_mpp_conf function with this saved list as first (mpp_conf) argment will set the configuration back.
--- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 10 +++++++++- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/mpp.c +9 -1
@@ -31,7 +31,7 @@ static u32 kirkwood_variant(void)#define MPP_CTRL (i) (KW_MPP_BASE + (i* 4))#define MPP_NR_REGS (1 + MPP_MAX/8) -void kirkwood_mpp_conf (u32 *mpp_list) +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save) {u32 mpp_ctrl[MPP_NR_REGS ];unsigned int variant_mask;
@@ -52,6 +52,7 @@ void kirkwood_mpp_conf(u32 *mpp_list)while (*mpp_list) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int sel_save;int shift;if (num >MPP_MAX ) {
@@ -66,6 +67,13 @@ void kirkwood_mpp_conf(u32 *mpp_list) } shift = (num &7 ) <<2 ; + +if (mpp_save) { + sel_save = (mpp_ctrl[num /8 ] >> shift) &0xf ; + *mpp_save = num | (sel_save <<8 ) | variant_mask; + mpp_save++; + } + mpp_ctrl[num /8 ] &= ~(0xf << shift); mpp_ctrl[num /8 ] |= sel << shift;
arch/arm/include/asm/arch-kirkwood/mpp.h +1 -1
@@ -312,6 +312,6 @@#define MPP_MAX 49 -void kirkwood_mpp_conf (unsigned int *mpp_list); +void kirkwood_mpp_conf (u32 *mpp_list,u32 *mpp_save);#endif
Signature · 1 line
1.7.1
PATCH v4 2/5 kirkwood: fix calls to kirkwood_mpp_conf
In reply to Valentin LongchampWith the new second save argument introduced by the previous patch, all the calls to the function had to be fixed.
--- board/LaCie/net2big_v2/net2big_v2.c | 2 +- board/LaCie/netspace_v2/netspace_v2.c | 2 +- board/Marvell/dreamplug/dreamplug.c | 2 +- board/Marvell/guruplug/guruplug.c | 2 +- board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c | 2 +- board/Marvell/openrd/openrd.c | 2 +- board/Marvell/rd6281a/rd6281a.c | 2 +- board/Marvell/sheevaplug/sheevaplug.c | 2 +- board/Seagate/dockstar/dockstar.c | 2 +- board/cloudengines/pogo_e02/pogo_e02.c | 2 +- board/d-link/dns325/dns325.c | 2 +- board/keymile/km_arm/km_arm.c | 6 +++--- board/raidsonic/ib62x0/ib62x0.c | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-)
board/LaCie/net2big_v2/net2big_v2.c +1 -1
@@ -75,7 +75,7 @@ int board_early_init_f(void) 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/LaCie/netspace_v2/netspace_v2.c +1 -1
@@ -73,7 +73,7 @@ int board_early_init_f(void)MPP33_GPIO ,/* Fan speed (bit 2) */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/dreamplug/dreamplug.c +1 -1
@@ -99,7 +99,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* Wifi AP LED */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/guruplug/guruplug.c +1 -1
@@ -96,7 +96,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* B_GLED */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c +1 -1
@@ -98,7 +98,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/openrd/openrd.c +1 -1
@@ -102,7 +102,7 @@ int board_early_init_f(void) 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/rd6281a/rd6281a.c +1 -1
@@ -97,7 +97,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/sheevaplug/sheevaplug.c +1 -1
@@ -96,7 +96,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Seagate/dockstar/dockstar.c +1 -1
@@ -100,7 +100,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/cloudengines/pogo_e02/pogo_e02.c +1 -1
@@ -71,7 +71,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* LED orange */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/d-link/dns325/dns325.c +1 -1
@@ -97,7 +97,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* thermal sensor */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );kw_gpio_set_blink (DNS325_GPIO_LED_POWER ,1 );
board/keymile/km_arm/km_arm.c +3 -3
@@ -244,7 +244,7 @@ int board_early_init_f(void) {u32 tmp; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );/* * The FLASH_GPIO_PIN switches between using a
@@ -299,7 +299,7 @@ int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) kwmpp_config[2 ] =MPP2_NF_IO4 ; kwmpp_config[3 ] =MPP3_NF_IO5 ; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL ); tmp =readl (KW_GPIO0_BASE );writel (tmp |FLASH_GPIO_PIN ,KW_GPIO0_BASE ); }else if ((strcmp (argv[1 ],"on" ) ==0 )) {
@@ -310,7 +310,7 @@ int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) kwmpp_config[2 ] =MPP2_SPI_SCK ; kwmpp_config[3 ] =MPP3_SPI_MISO ; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL ); tmp =readl (KW_GPIO0_BASE );writel (tmp & (~FLASH_GPIO_PIN ) ,KW_GPIO0_BASE ); }else {
board/raidsonic/ib62x0/ib62x0.c +1 -1
@@ -66,7 +66,7 @@ int board_early_init_f(void)MPP29_GPIO ,/* USB Copy button */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
Signature · 1 line
1.7.1
PATCH v4 3/5 kw_spi: backup and reset the MPP of the chosen CS pin
In reply to Valentin LongchampThis was not done before, and in the case of a shared pin (for MPP0 between NF_IO[2] and CSn) this could lead to problems.
--- drivers/spi/kirkwood_spi.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-)
drivers/spi/kirkwood_spi.c +6 -9
@@ -34,16 +34,14 @@static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE ; +u32 cs_spi_mpp_back[2 ]; +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs,unsigned int max_hz,unsigned int mode) {struct spi_slave *slave;u32 data; -u32 kwspi_mpp_config[] = { -MPP0_GPIO , - MPP7_SPI_SCn, -0 - }; +u32 kwspi_mpp_config[] = {0 ,0 };if (!spi_cs_is_valid (bus, cs))return NULL ;
@@ -70,19 +68,18 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,/* program mpp registers to select SPI_CSn */ if (cs) { - kwspi_mpp_config[0 ] =MPP0_GPIO ; - kwspi_mpp_config[1 ] = MPP7_SPI_SCn; + kwspi_mpp_config[0 ] = MPP7_SPI_SCn; }else { kwspi_mpp_config[0 ] = MPP0_SPI_SCn; - kwspi_mpp_config[1 ] =MPP7_GPO ; } -kirkwood_mpp_conf (kwspi_mpp_config); +kirkwood_mpp_conf (kwspi_mpp_config, cs_spi_mpp_back);return slave; }void spi_free_slave (struct spi_slave *slave) { +kirkwood_mpp_conf (cs_spi_mpp_back,NULL );free (slave); }
Signature · 1 line
1.7.1
PATCH v4 4/5 kw_spi: support spi_claim/release_bus functions
In reply to Valentin LongchampThese two function nows ensure that the MPP is configured correctly for the SPI controller before any SPI access, and restore the initial configuration when the access is over.
Since the used pins for the SPI controller can differ (2 possibilities for each signal), the used pins are configured with CONFIG_SYS_KW_SPI_MPP.
--- arch/arm/include/asm/arch-kirkwood/spi.h | 11 +++++++++ drivers/spi/kirkwood_spi.c | 36 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-kirkwood/spi.h +11 -0
@@ -37,6 +37,17 @@ struct kwspi_registers {u32 irq_mask;/* 0x10614 */ }; +/* They are used to define CONFIG_SYS_KW_SPI_MPP +* each of the below #defines selects which mpp is +* configured for each SPI signal in spi_claim_bus +* bit 0: selects pin for MOSI (MPP1 if 0, MPP6 if 1) +* bit 1: selects pin for SCK (MPP2 if 0, MPP10 if 1) +* bit 2: selects pin for MISO (MPP3 if 0, MPP11 if 1) +*/ +#define MOSI_MPP6 (1 << 0) +#define SCK_MPP10 (1 << 1) +#define MISO_MPP11 (1 << 2) +#define KWSPI_CLKPRESCL_MASK 0x1f#define KWSPI_CSN_ACT 1/* Activates serial memory interface */ #define KWSPI_SMEMRDY (1 << 1)/* SerMem Data xfer ready */
drivers/spi/kirkwood_spi.c +36 -0
@@ -83,13 +83,49 @@ void spi_free_slave(struct spi_slave *slave)free (slave); } +#if defined(CONFIG_SYS_KW_SPI_MPP ) +u32 spi_mpp_backup[4 ]; +#endif +int spi_claim_bus (struct spi_slave *slave) { +#if defined(CONFIG_SYS_KW_SPI_MPP ) +u32 config; +u32 spi_mpp_config[4 ]; + + config =CONFIG_SYS_KW_SPI_MPP ; + +if (config &MOSI_MPP6 ) + spi_mpp_config[0 ] =MPP6_SPI_MOSI ; +else + spi_mpp_config[0 ] =MPP1_SPI_MOSI ; + +if (config &SCK_MPP10 ) + spi_mpp_config[1 ] =MPP10_SPI_SCK ; +else + spi_mpp_config[1 ] =MPP2_SPI_SCK ; + +if (config &MISO_MPP11 ) + spi_mpp_config[2 ] =MPP11_SPI_MISO ; +else + spi_mpp_config[2 ] =MPP3_SPI_MISO ; + + spi_mpp_config[3 ] =0 ; + spi_mpp_backup[3 ] =0 ; + +/* set new spi mpp and save current mpp config */ +kirkwood_mpp_conf (spi_mpp_config, spi_mpp_backup); + +#endif +return 0 ; }void spi_release_bus (struct spi_slave *slave) { +#if defined(CONFIG_SYS_KW_SPI_MPP ) +kirkwood_mpp_conf (spi_mpp_backup,NULL ); +#endif }#ifndef CONFIG_SPI_CS_IS_VALID
Signature · 1 line
1.7.1
PATCH v4 5/5 kw_spi: add weak functions board_spi_claim/release_bus
In reply to Valentin LongchampThis allows a final, board specific, step in the claim/relase_bus function for the SPI controller, which may be needed for some hardware designs.
--- drivers/spi/kirkwood_spi.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
drivers/spi/kirkwood_spi.c +12 -1
@@ -87,6 +87,11 @@ void spi_free_slave(struct spi_slave *slave)u32 spi_mpp_backup[4 ];#endif +__attribute__((weak))int board_spi_claim_bus (struct spi_slave *slave) +{ +return 0 ; +} +int spi_claim_bus (struct spi_slave *slave) {#if defined(CONFIG_SYS_KW_SPI_MPP )
@@ -118,7 +123,11 @@ int spi_claim_bus(struct spi_slave *slave)#endif -return 0 ; +return board_spi_claim_bus (slave); +} + +__attribute__((weak))void board_spi_release_bus (struct spi_slave *slave) +{ }void spi_release_bus (struct spi_slave *slave)
@@ -126,6 +135,8 @@ void spi_release_bus(struct spi_slave *slave)#if defined(CONFIG_SYS_KW_SPI_MPP )kirkwood_mpp_conf (spi_mpp_backup,NULL );#endif + +board_spi_release_bus (slave); }#ifndef CONFIG_SPI_CS_IS_VALID
Signature · 1 line
1.7.1
PATCH v4 5/5 wispy: add weak functions board_spi_claim/release_bus
Quoted 10 lines
-----Original Message-----
From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
Sent: 01 June 2012 17:01
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Valentin Longchamp; Holger Brunck
Subject: [PATCH v4 5/5]kw_spi: add weak functions board_spi_claim/release_bus
Quoted 8 lines
This allows a final, board specific, step in the claim/relase_bus function for the SPI controller, which may be needed for some hardware designs.
Signed-off-by Valentin Longchamp <[email protected]>cc Holger Brunck <[email protected]>cc Prafulla Wadaskar <[email protected]>---
Applied this entire patch series to u-boot-marvell.git master branch
Regards..
Prafulla . . .
PATCH v4 5/5 wispy: add weak functions board_spi_claim/release_bus
Hi Prafulla,
Quoted 12 lines · Prafulla Wadaskar
Quoted 12 lines
-----Original Message-----
From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
Sent: 01 June 2012 17:01
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Valentin Longchamp; Holger Brunck
Subject: [PATCH v4 5/5]kw_spi: add weak functions board_spi_claim/release_busThis allows a final, board specific, step in the claim/relase_bus function for the SPI controller, which may be needed for some hardware designs.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Valentin Longchamp <[email protected]>cc Holger Brunck <[email protected]>cc Prafulla Wadaskar <[email protected]>---
Applied this entire patch series to u-boot-marvell.git master branch
Thank you for applying this patch series. I will now send you the third series as you discussed it with Holger
(http://lists.denx.de/pipermail/u-boot/2012-May/125208.html), which contains the patches for the support of new boards and new features for Keymile boards.
Valentin
PATCH v3 2/5 kirkwood: fix calls to kirkwood_mpp_conf
In reply to Valentin LongchampWith the new second save argument introduced by the previous patch, all the calls to the function had to be fixed.
--- board/LaCie/net2big_v2/net2big_v2.c | 2 +- board/LaCie/netspace_v2/netspace_v2.c | 2 +- board/Marvell/dreamplug/dreamplug.c | 2 +- board/Marvell/guruplug/guruplug.c | 2 +- board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c | 2 +- board/Marvell/openrd/openrd.c | 2 +- board/Marvell/rd6281a/rd6281a.c | 2 +- board/Marvell/sheevaplug/sheevaplug.c | 2 +- board/Seagate/dockstar/dockstar.c | 2 +- board/cloudengines/pogo_e02/pogo_e02.c | 2 +- board/d-link/dns325/dns325.c | 2 +- board/keymile/km_arm/km_arm.c | 6 +++--- board/raidsonic/ib62x0/ib62x0.c | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-)
board/LaCie/net2big_v2/net2big_v2.c +1 -1
@@ -75,7 +75,7 @@ int board_early_init_f(void) 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/LaCie/netspace_v2/netspace_v2.c +1 -1
@@ -73,7 +73,7 @@ int board_early_init_f(void)MPP33_GPIO ,/* Fan speed (bit 2) */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/dreamplug/dreamplug.c +1 -1
@@ -99,7 +99,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* Wifi AP LED */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/guruplug/guruplug.c +1 -1
@@ -96,7 +96,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* B_GLED */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c +1 -1
@@ -98,7 +98,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/openrd/openrd.c +1 -1
@@ -102,7 +102,7 @@ int board_early_init_f(void) 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/rd6281a/rd6281a.c +1 -1
@@ -97,7 +97,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Marvell/sheevaplug/sheevaplug.c +1 -1
@@ -96,7 +96,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/Seagate/dockstar/dockstar.c +1 -1
@@ -100,7 +100,7 @@ int board_early_init_f(void)MPP49_GPIO , 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/cloudengines/pogo_e02/pogo_e02.c +1 -1
@@ -71,7 +71,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* LED orange */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
board/d-link/dns325/dns325.c +1 -1
@@ -97,7 +97,7 @@ int board_early_init_f(void)MPP49_GPIO ,/* thermal sensor */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );kw_gpio_set_blink (DNS325_GPIO_LED_POWER ,1 );
board/keymile/km_arm/km_arm.c +3 -3
@@ -244,7 +244,7 @@ int board_early_init_f(void) {u32 tmp; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );/* * The FLASH_GPIO_PIN switches between using a
@@ -299,7 +299,7 @@ int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) kwmpp_config[2 ] =MPP2_NF_IO4 ; kwmpp_config[3 ] =MPP3_NF_IO5 ; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL ); tmp =readl (KW_GPIO0_BASE );writel (tmp |FLASH_GPIO_PIN ,KW_GPIO0_BASE ); }else if ((strcmp (argv[1 ],"on" ) ==0 )) {
@@ -310,7 +310,7 @@ int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) kwmpp_config[2 ] =MPP2_SPI_SCK ; kwmpp_config[3 ] =MPP3_SPI_MISO ; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL ); tmp =readl (KW_GPIO0_BASE );writel (tmp & (~FLASH_GPIO_PIN ) ,KW_GPIO0_BASE ); }else {
board/raidsonic/ib62x0/ib62x0.c +1 -1
@@ -66,7 +66,7 @@ int board_early_init_f(void)MPP29_GPIO ,/* USB Copy button */ 0 }; -kirkwood_mpp_conf (kwmpp_config); +kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
Signature · 1 line
1.7.1
PATCH v3 3/5 kw_spi: backup and reset the MPP of the chosen CS pin
In reply to Valentin LongchampThis was not done before, and in the case of a shared pin (for MPP0 between NF_IO[2] and CSn) this could lead to problems.
--- drivers/spi/kirkwood_spi.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-)
drivers/spi/kirkwood_spi.c +6 -9
@@ -34,16 +34,14 @@static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE ; +u32 cs_spi_mpp_back[2 ]; +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs,unsigned int max_hz,unsigned int mode) {struct spi_slave *slave;u32 data; -u32 kwspi_mpp_config[] = { -MPP0_GPIO , - MPP7_SPI_SCn, -0 - }; +u32 kwspi_mpp_config[] = {0 ,0 };if (!spi_cs_is_valid (bus, cs))return NULL ;
@@ -70,19 +68,18 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,/* program mpp registers to select SPI_CSn */ if (cs) { - kwspi_mpp_config[0 ] =MPP0_GPIO ; - kwspi_mpp_config[1 ] = MPP7_SPI_SCn; + kwspi_mpp_config[0 ] = MPP7_SPI_SCn; }else { kwspi_mpp_config[0 ] = MPP0_SPI_SCn; - kwspi_mpp_config[1 ] =MPP7_GPO ; } -kirkwood_mpp_conf (kwspi_mpp_config); +kirkwood_mpp_conf (kwspi_mpp_config, cs_spi_mpp_back);return slave; }void spi_free_slave (struct spi_slave *slave) { +kirkwood_mpp_conf (cs_spi_mpp_back,NULL );free (slave); }
Signature · 1 line
1.7.1
PATCH v3 4/5 kw_spi: support spi_claim/release_bus functions
In reply to Valentin LongchampThese two function nows ensure that the MPP is configured correctly for the SPI controller before any SPI access, and restore the initial configuration when the access is over.
Since the used pins for the SPI controller can differ (2 possibilities for each signal), the used pins are configured with CONFIG_SYS_KW_SPI_MPP.
--- arch/arm/include/asm/arch-kirkwood/spi.h | 11 +++++++++ drivers/spi/kirkwood_spi.c | 36 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-kirkwood/spi.h +11 -0
@@ -37,6 +37,17 @@ struct kwspi_registers {u32 irq_mask;/* 0x10614 */ }; +/* They are used to define CONFIG_SYS_KW_SPI_MPP +* each of the below #defines selects which mpp is +* configured for each SPI signal in spi_claim_bus +* bit 0: selects pin for MOSI (MPP1 if 0, MPP6 if 1) +* bit 1: selects pin for SCK (MPP2 if 0, MPP10 if 1) +* bit 2: selects pin for MISO (MPP3 if 0, MPP11 if 1) +*/ +#define MOSI_MPP6 (1 << 0) +#define SCK_MPP10 (1 << 1) +#define MISO_MPP11 (1 << 2) +#define KWSPI_CLKPRESCL_MASK 0x1f#define KWSPI_CSN_ACT 1/* Activates serial memory interface */ #define KWSPI_SMEMRDY (1 << 1)/* SerMem Data xfer ready */
drivers/spi/kirkwood_spi.c +36 -0
@@ -83,13 +83,49 @@ void spi_free_slave(struct spi_slave *slave)free (slave); } +#if defined(CONFIG_SYS_KW_SPI_MPP ) +u32 spi_mpp_backup[4 ]; +#endif +int spi_claim_bus (struct spi_slave *slave) { +#if defined(CONFIG_SYS_KW_SPI_MPP ) +u32 config; +u32 spi_mpp_config[4 ]; + + config =CONFIG_SYS_KW_SPI_MPP ; + +if (config &MOSI_MPP6 ) + spi_mpp_config[0 ] =MPP6_SPI_MOSI ; +else + spi_mpp_config[0 ] =MPP1_SPI_MOSI ; + +if (config &SCK_MPP10 ) + spi_mpp_config[1 ] =MPP10_SPI_SCK ; +else + spi_mpp_config[1 ] =MPP2_SPI_SCK ; + +if (config &MISO_MPP11 ) + spi_mpp_config[2 ] =MPP11_SPI_MISO ; +else + spi_mpp_config[2 ] =MPP3_SPI_MISO ; + + spi_mpp_config[3 ] =0 ; + spi_mpp_backup[3 ] =0 ; + +/* set new spi mpp and save current mpp config */ +kirkwood_mpp_conf (spi_mpp_config, spi_mpp_backup); + +#endif +return 0 ; }void spi_release_bus (struct spi_slave *slave) { +#if defined(CONFIG_SYS_KW_SPI_MPP ) +kirkwood_mpp_conf (spi_mpp_backup,NULL ); +#endif }#ifndef CONFIG_SPI_CS_IS_VALID
Signature · 1 line
1.7.1
PATCH v3 5/5 kw_spi: add weak functions board_spi_claim/release_bus
In reply to Valentin LongchampThis allows a final, board specific, step in the claim/relase_bus function for the SPI controller, which may be needed for some hardware designs.
--- drivers/spi/kirkwood_spi.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
drivers/spi/kirkwood_spi.c +12 -1
@@ -87,6 +87,11 @@ void spi_free_slave(struct spi_slave *slave)u32 spi_mpp_backup[4 ];#endif +__attribute__((weak))int board_spi_claim_bus (struct spi_slave *slave) +{ +return 0 ; +} +int spi_claim_bus (struct spi_slave *slave) {#if defined(CONFIG_SYS_KW_SPI_MPP )
@@ -118,7 +123,11 @@ int spi_claim_bus(struct spi_slave *slave)#endif -return 0 ; +return board_spi_claim_bus (slave); +} + +__attribute__((weak))void board_spi_release_bus (struct spi_slave *slave) +{ }void spi_release_bus (struct spi_slave *slave)
@@ -126,6 +135,8 @@ void spi_release_bus(struct spi_slave *slave)#if defined(CONFIG_SYS_KW_SPI_MPP )kirkwood_mpp_conf (spi_mpp_backup,NULL );#endif + +board_spi_release_bus (slave); }#ifndef CONFIG_SPI_CS_IS_VALID
Signature · 1 line
1.7.1