MIPS: uaccess: emulate Ingenic LXW/LXH/LXHU uaccess
Subsystems (4)
Paul Cercueil
maintainerPATCH 1/4 MIPS: uaccess: emulate Ingenic LXW/LXH/LXHU uaccess
From: Siarhei Volkau <[email protected]>
The LXW, LXH, LXHU opcodes are part of the MXU ASE found in Ingenic XBurst based SoCs.
While technically part of the MXU ASE, they do not touch any of the SIMD registers, and can be used even when the MXU ASE is disabled.
This patch makes it possible to emulate unaligned access for those instructions.
--- arch/mips/include/uapi/asm/inst.h | 33 +++++++++++++++++++++++++ arch/mips/kernel/unaligned.c | 41 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+)
arch/mips/include/uapi/asm/inst.h +33 -0
@@ -272,6 +272,27 @@ enum lx_func { lbx_op = 0x16, }; +/* +* func field for special2 MXU opcodes (Ingenic XBurst MXU). +*/ +enum mxu_func { +/* TODO, other MXU funcs */ + mxu_lx_op =0x28 , +}; + +/* +* op field for special2 MXU LX opcodes (Ingenic XBurst MXU). +*/ +enum lx_ingenic_func { + mxu_lxb_op, + mxu_lxh_op, +/* reserved */ + mxu_lxw_op =3 , + mxu_lxbu_op, + mxu_lxhu_op, +/* more reserved */ +}; +/* * BSHFL opcodes */
@@ -774,6 +795,17 @@ struct dsp_format { /* SPEC3 DSP format instructions */ ;)))))) }; +struct mxu_lx_format { /* SPEC2 MXU LX format instructions */ + __BITFIELD_FIELD(unsigned int opcode : 6, + __BITFIELD_FIELD(unsigned int rs : 5, + __BITFIELD_FIELD(unsigned int rt : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + __BITFIELD_FIELD(unsigned int strd : 2, + __BITFIELD_FIELD(unsigned int op : 3, + __BITFIELD_FIELD(unsigned int func : 6, + ;))))))) +}; + struct spec3_format { /* SPEC3 */ __BITFIELD_FIELD(unsigned int opcode:6, __BITFIELD_FIELD(unsigned int rs:5,
@@ -1125,6 +1157,7 @@ union mips_instruction {struct loongson3_lswc2_format loongson3_lswc2_format;struct loongson3_lsdc2_format loongson3_lsdc2_format;struct loongson3_lscsr_format loongson3_lscsr_format; +struct mxu_lx_format mxu_lx_format; };union mips16e_instruction {
arch/mips/kernel/unaligned.c +41 -0
47 lines not on this page · raw message
Signature · 1 line
2.39.2
Paul Cercueil
maintainerPATCH 2/4 mips: ingenic: Remove useless __maybe_unused
These flags are useless in this case as the code referencing these data structures is always seen by the compiler (and not behind #ifdef guards).
--- arch/mips/generic/board-ingenic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/generic/board-ingenic.c +2 -2
@@ -117,14 +117,14 @@ static void ingenic_halt(void)ingenic_wait_instr (); } -static int __maybe_unused ingenic_pm_enter (suspend_state_t state) +static int ingenic_pm_enter (suspend_state_t state) {ingenic_wait_instr ();return 0 ; } -static const struct platform_suspend_ops ingenic_pm_ops__maybe_unused = { +static const struct platform_suspend_ops ingenic_pm_ops = { .valid = suspend_valid_only_mem, .enter = ingenic_pm_enter, };
Signature · 1 line
2.39.2
Re: [PATCH 2/4] mips: ingenic: Remove useless __maybe_unused
Quoted 32 lines · Paul Cercueil
These flags are useless in this case as the code referencing these data structures is always seen by the compiler (and not behind #ifdef guards).
Signed-off-by Paul Cercueil <[email protected]>--- arch/mips/generic/board-ingenic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/mips/generic/board-ingenic.c +2
-2@@ -117,14 +117,14 @@ static void ingenic_halt(void)ingenic_wait_instr (); } -static int __maybe_unused ingenic_pm_enter (suspend_state_t state) +static int ingenic_pm_enter (suspend_state_t state) {ingenic_wait_instr ();return 0 ; } -static const struct platform_suspend_ops ingenic_pm_ops__maybe_unused = { +static const struct platform_suspend_ops ingenic_pm_ops = { .valid = suspend_valid_only_mem, .enter = ingenic_pm_enter, };Signature · 1 line
2.39.2
applied to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Paul Cercueil
maintainerPATCH 3/4 mips: ingenic: Enable EXT/2 divider on JZ4750/55/60 if EXT is 24 MHz
In reply to Paul CercueilThe JZ4750, JZ4755 and JZ4760 (non-B version) support using a 24 MHz external crystal oscillator instead of the typical 12 MHz one.
However, most of the SoC's IP blocks only work with a 12 MHz clock. Thanksfully, there is a /2 divider we can enable when a 24 MHz external crystal is present.
Force-enable this /2 divider when the oscillator is 24 MHz, so that the SoC always uses a 12 MHz clock internally.
It is done here, and not in the clocks driver, because we need the EXT clock to be 12 MHz for the early console to work, and the clocks driver probes way too late.
--- arch/mips/generic/board-ingenic.c | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
arch/mips/generic/board-ingenic.c +57 -0
@@ -17,6 +17,7 @@#include <linux/types.h> #include <asm/bootinfo.h> +#include <asm/io.h> #include <asm/machine.h> #include <asm/reboot.h>
@@ -60,6 +61,50 @@ static __init char *ingenic_get_system_type(unsigned long machtype) } } +#define INGENIC_CGU_BASE 0x10000000 +#define JZ4750_CGU_CPCCR_ECS BIT(30) +#define JZ4760_CGU_CPCCR_ECS BIT(31) + +static __init void ingenic_force_12M_ext (const void *fdt,unsigned int mask) +{ +const __be32 *prop; +unsigned int cpccr; +void __iomem *cgu; +bool use_div; +int offset; + + offset =fdt_path_offset (fdt,"/ext" ); +if (offset <0 ) +return ; + + prop =fdt_getprop (fdt, offset,"clock-frequency" ,NULL ); +if (!prop) +return ; + +/* +* If the external oscillator is 24 MHz, enable the /2 divider to +* drive it down to 12 MHz, since this is what the hardware can work +* with. +* The 16 MHz cutoff value is arbitrary; setting it to 12 MHz would not +* work as the crystal frequency (as reported in the Device Tree) might +* be slightly above this value. +*/ + use_div =be32_to_cpup (prop) >=16000000 ; + + cgu =ioremap (INGENIC_CGU_BASE ,0x4 ); +if (!cgu) +return ; + + cpccr =ioread32 (cgu); +if (use_div) + cpccr |= mask; +else + cpccr &= ~mask; +iowrite32 (cpccr, cgu); + +iounmap (cgu); +} +static __init const void *ingenic_fixup_fdt (const void *fdt,const void *match_data) {/*
@@ -73,6 +118,18 @@ static __init const void *ingenic_fixup_fdt(const void *fdt, const void *match_d mips_machtype = (unsigned long )match_data; system_type =ingenic_get_system_type (mips_machtype); +switch (mips_machtype) { +case MACH_INGENIC_JZ4750 : +case MACH_INGENIC_JZ4755 : +ingenic_force_12M_ext (fdt,JZ4750_CGU_CPCCR_ECS ); +break ; +case MACH_INGENIC_JZ4760 : +ingenic_force_12M_ext (fdt,JZ4760_CGU_CPCCR_ECS ); +break ; +default : +break ; + } +return fdt; }
Signature · 1 line
2.39.2
Re: [PATCH 3/4] mips: ingenic: Enable EXT/2 divider on JZ4750/55/60 if EXT is 24 MHz
Quoted 10 lines · Paul Cercueil
The JZ4750, JZ4755 and JZ4760 (non-B version) support using a 24 MHz external crystal oscillator instead of the typical 12 MHz one.
However, most of the SoC's IP blocks only work with a 12 MHz clock. Thanksfully, there is a /2 divider we can enable when a 24 MHz external crystal is present.
Force-enable this /2 divider when the oscillator is 24 MHz, so that the SoC always uses a 12 MHz clock internally.
Quoted 8 lines
It is done here, and not in the clocks driver, because we need the EXT clock to be 12 MHz for the early console to work, and the clocks driver probes way too late.
Signed-off-by Paul Cercueil <[email protected]>--- arch/mips/generic/board-ingenic.c | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
applied to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Paul Cercueil
maintainerPATCH 4/4 MIPS: DTS: qi_lb60: Don't use unit address for regulators
In reply to Paul CercueilThe regulators don't have any "reg" property, and therefore shouldn't use an unit address in their node names.
---
Cc: Rob Herring <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: [email protected]
--- arch/mips/boot/dts/ingenic/qi_lb60.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/boot/dts/ingenic/qi_lb60.dts +3 -3
@@ -27,7 +27,7 @@ chosen { stdout-path = &uart0; }; - vcc: regulator@0 { + vcc: regulator-0 { compatible = "regulator-fixed"; regulator-name = "vcc";
@@ -36,7 +36,7 @@ vcc: regulator@0 { regulator-always-on; }; - mmc_power: regulator@1 { + mmc_power: regulator-1 { compatible = "regulator-fixed"; regulator-name = "mmc_vcc"; gpio = <&gpd 2 0>;
@@ -45,7 +45,7 @@ mmc_power: regulator@1 { regulator-max-microvolt = <3300000>; }; - amp_supply: regulator@2 { + amp_supply: regulator-2 { compatible = "regulator-fixed"; regulator-name = "amp_supply"; gpio = <&gpd 4 0>;
Signature · 1 line
2.39.2
Re: [PATCH 4/4] MIPS: DTS: qi_lb60: Don't use unit address for regulators
Quoted 4 lines · Paul Cercueil
The regulators don't have any "reg" property, and therefore shouldn't use an unit address in their node names.
Signed-off-by Paul Cercueil <[email protected]>
Quoted 8 lines
---
Cc: Rob Herring <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: [email protected]--- arch/mips/boot/dts/ingenic/qi_lb60.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
applied to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Quoted 8 lines · Paul Cercueil
From: Siarhei Volkau <[email protected]>
The LXW, LXH, LXHU opcodes are part of the MXU ASE found in Ingenic XBurst based SoCs.
While technically part of the MXU ASE, they do not touch any of the SIMD registers, and can be used even when the MXU ASE is disabled.
Quoted 8 lines
This patch makes it possible to emulate unaligned access for those instructions.
Signed-off-by Siarhei Volkau <[email protected]>--- arch/mips/include/uapi/asm/inst.h | 33 +++++++++++++++++++++++++ arch/mips/kernel/unaligned.c | 41 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+)
applied to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]