2019-05-27 09:55:01 +03:00
// SPDX-License-Identifier: GPL-2.0-or-later
2007-09-13 15:32:02 +04:00
/*
* MIPS SPRAM support
*
* Copyright ( C ) 2007 , 2008 MIPS Technologies , Inc .
*/
# include <linux/kernel.h>
# include <linux/ptrace.h>
# include <linux/stddef.h>
# include <asm/fpu.h>
# include <asm/mipsregs.h>
# include <asm/r4kcache.h>
# include <asm/hazards.h>
/*
* These definitions are correct for the 24 K / 34 K / 74 K SPRAM sample
* implementation . The 4 KS interpreted the tags differently . . .
*/
# define SPRAM_TAG0_ENABLE 0x00000080
# define SPRAM_TAG0_PA_MASK 0xfffff000
# define SPRAM_TAG1_SIZE_MASK 0xfffff000
# define SPRAM_TAG_STRIDE 8
# define ERRCTL_SPRAM (1 << 28)
/* errctl access */
# define read_c0_errctl(x) read_c0_ecc(x)
# define write_c0_errctl(x) write_c0_ecc(x)
/*
* Different semantics to the set_c0_ * function built by __BUILD_SET_C0
*/
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
static unsigned int bis_c0_errctl ( unsigned int set )
2007-09-13 15:32:02 +04:00
{
unsigned int res ;
res = read_c0_errctl ( ) ;
write_c0_errctl ( res | set ) ;
return res ;
}
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
static void ispram_store_tag ( unsigned int offset , unsigned int data )
2007-09-13 15:32:02 +04:00
{
unsigned int errctl ;
/* enable SPRAM tag access */
errctl = bis_c0_errctl ( ERRCTL_SPRAM ) ;
ehb ( ) ;
write_c0_taglo ( data ) ;
ehb ( ) ;
cache_op ( Index_Store_Tag_I , CKSEG0 | offset ) ;
ehb ( ) ;
write_c0_errctl ( errctl ) ;
ehb ( ) ;
}
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
static unsigned int ispram_load_tag ( unsigned int offset )
2007-09-13 15:32:02 +04:00
{
unsigned int data ;
unsigned int errctl ;
/* enable SPRAM tag access */
errctl = bis_c0_errctl ( ERRCTL_SPRAM ) ;
ehb ( ) ;
cache_op ( Index_Load_Tag_I , CKSEG0 | offset ) ;
ehb ( ) ;
data = read_c0_taglo ( ) ;
ehb ( ) ;
write_c0_errctl ( errctl ) ;
ehb ( ) ;
return data ;
}
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
static void dspram_store_tag ( unsigned int offset , unsigned int data )
2007-09-13 15:32:02 +04:00
{
unsigned int errctl ;
/* enable SPRAM tag access */
errctl = bis_c0_errctl ( ERRCTL_SPRAM ) ;
ehb ( ) ;
write_c0_dtaglo ( data ) ;
ehb ( ) ;
cache_op ( Index_Store_Tag_D , CKSEG0 | offset ) ;
ehb ( ) ;
write_c0_errctl ( errctl ) ;
ehb ( ) ;
}
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
static unsigned int dspram_load_tag ( unsigned int offset )
2007-09-13 15:32:02 +04:00
{
unsigned int data ;
unsigned int errctl ;
errctl = bis_c0_errctl ( ERRCTL_SPRAM ) ;
ehb ( ) ;
cache_op ( Index_Load_Tag_D , CKSEG0 | offset ) ;
ehb ( ) ;
data = read_c0_dtaglo ( ) ;
ehb ( ) ;
write_c0_errctl ( errctl ) ;
ehb ( ) ;
return data ;
}
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
static void probe_spram ( char * type ,
2007-09-13 15:32:02 +04:00
unsigned int base ,
unsigned int ( * read ) ( unsigned int ) ,
void ( * write ) ( unsigned int , unsigned int ) )
{
unsigned int firstsize = 0 , lastsize = 0 ;
unsigned int firstpa = 0 , lastpa = 0 , pa = 0 ;
unsigned int offset = 0 ;
unsigned int size , tag0 , tag1 ;
unsigned int enabled ;
int i ;
/*
* The limit is arbitrary but avoids the loop running away if
* the SPRAM tags are implemented differently
*/
for ( i = 0 ; i < 8 ; i + + ) {
tag0 = read ( offset ) ;
tag1 = read ( offset + SPRAM_TAG_STRIDE ) ;
pr_debug ( " DBG %s%d: tag0=%08x tag1=%08x \n " ,
type , i , tag0 , tag1 ) ;
size = tag1 & SPRAM_TAG1_SIZE_MASK ;
if ( size = = 0 )
break ;
if ( i ! = 0 ) {
/* tags may repeat... */
if ( ( pa = = firstpa & & size = = firstsize ) | |
( pa = = lastpa & & size = = lastsize ) )
break ;
}
/* Align base with size */
base = ( base + size - 1 ) & ~ ( size - 1 ) ;
/* reprogram the base address base address and enable */
tag0 = ( base & SPRAM_TAG0_PA_MASK ) | SPRAM_TAG0_ENABLE ;
write ( offset , tag0 ) ;
base + = size ;
/* reread the tag */
tag0 = read ( offset ) ;
pa = tag0 & SPRAM_TAG0_PA_MASK ;
enabled = tag0 & SPRAM_TAG0_ENABLE ;
if ( i = = 0 ) {
firstpa = pa ;
firstsize = size ;
}
lastpa = pa ;
lastsize = size ;
if ( strcmp ( type , " DSPRAM " ) = = 0 ) {
unsigned int * vp = ( unsigned int * ) ( CKSEG1 | pa ) ;
unsigned int v ;
# define TDAT 0x5a5aa5a5
vp [ 0 ] = TDAT ;
vp [ 1 ] = ~ TDAT ;
mb ( ) ;
v = vp [ 0 ] ;
if ( v ! = TDAT )
printk ( KERN_ERR " vp=%p wrote=%08x got=%08x \n " ,
vp , TDAT , v ) ;
v = vp [ 1 ] ;
if ( v ! = ~ TDAT )
printk ( KERN_ERR " vp=%p wrote=%08x got=%08x \n " ,
vp + 1 , ~ TDAT , v ) ;
}
pr_info ( " %s%d: PA=%08x,Size=%08x%s \n " ,
type , i , pa , size , enabled ? " ,enabled " : " " ) ;
offset + = 2 * SPRAM_TAG_STRIDE ;
}
}
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 17:38:59 +04:00
void spram_config ( void )
2007-09-13 15:32:02 +04:00
{
unsigned int config0 ;
2010-12-25 23:42:37 +03:00
switch ( current_cpu_type ( ) ) {
2007-09-13 15:32:02 +04:00
case CPU_24K :
case CPU_34K :
case CPU_74K :
2009-10-13 01:20:20 +04:00
case CPU_1004K :
2014-01-18 01:03:50 +04:00
case CPU_1074K :
2013-11-27 14:07:53 +04:00
case CPU_INTERAPTIV :
2013-11-14 20:12:27 +04:00
case CPU_PROAPTIV :
2014-01-22 20:19:38 +04:00
case CPU_P5600 :
2014-11-24 15:59:01 +03:00
case CPU_QEMU_GENERIC :
2015-07-09 12:40:36 +03:00
case CPU_I6400 :
2016-02-03 06:26:38 +03:00
case CPU_P6600 :
2007-09-13 15:32:02 +04:00
config0 = read_c0_config ( ) ;
/* FIXME: addresses are Malta specific */
mips: Add CONFIG/CONFIG6/Cause reg fields macro
There are bit fields which persist in the MIPS CONFIG and CONFIG6
registers, but haven't been described in the generic mipsregs.h
header so far. In particular, the generic CONFIG bitfields are
BE - endian mode, BM - burst mode, SB - SimpleBE, OCP interface mode
indicator, UDI - user-defined "CorExtend" instructions, DSP - data
scratch pad RAM present, ISP - instruction scratch pad RAM present,
etc. The core-specific CONFIG6 bitfields are JRCD - jump register
cache prediction disable, R6 - MIPSr6 extensions enable, IFUPerfCtl -
IFU performance control, SPCD - sleep state performance counter, DLSB -
disable load/store bonding. A new exception code reported in the
ExcCode field of the Cause register: 30 - Parity/ECC error exception
happened on either fetch, load or cache refill. Lets add them to the
mipsregs.h header to be used in future platform code, which have them
utilized.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-21 17:07:18 +03:00
if ( config0 & MIPS_CONF_ISP ) {
2007-09-13 15:32:02 +04:00
probe_spram ( " ISPRAM " , 0x1c000000 ,
& ispram_load_tag , & ispram_store_tag ) ;
}
mips: Add CONFIG/CONFIG6/Cause reg fields macro
There are bit fields which persist in the MIPS CONFIG and CONFIG6
registers, but haven't been described in the generic mipsregs.h
header so far. In particular, the generic CONFIG bitfields are
BE - endian mode, BM - burst mode, SB - SimpleBE, OCP interface mode
indicator, UDI - user-defined "CorExtend" instructions, DSP - data
scratch pad RAM present, ISP - instruction scratch pad RAM present,
etc. The core-specific CONFIG6 bitfields are JRCD - jump register
cache prediction disable, R6 - MIPSr6 extensions enable, IFUPerfCtl -
IFU performance control, SPCD - sleep state performance counter, DLSB -
disable load/store bonding. A new exception code reported in the
ExcCode field of the Cause register: 30 - Parity/ECC error exception
happened on either fetch, load or cache refill. Lets add them to the
mipsregs.h header to be used in future platform code, which have them
utilized.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-21 17:07:18 +03:00
if ( config0 & MIPS_CONF_DSP )
2007-09-13 15:32:02 +04:00
probe_spram ( " DSPRAM " , 0x1c100000 ,
& dspram_load_tag , & dspram_store_tag ) ;
}
}