Re: [PATCH v2 00/28] sparc32: sunset sun4m and sun4d

2024-04-23 Thread Sam Ravnborg
Hi Andreas,

On Sat, Mar 09, 2024 at 07:15:21PM +0100, Sam Ravnborg via B4 Relay wrote:
> This is the second attempt to sunset sun4m and sun4d.
> See [1] for the inital attempt.
> 
> The sun4m and sun4d parts of the kernel have seen no real interest
> for several years now. Last time a few people surfaced, but it was
> either due to a personal project or for nostalgic reasons.
> It is time to let go and drop the parts of sparc32 that in reality
> are not in use.
> 
> LEON from Frontgrade Gaisler is the only real user of sparc32,
> and this patchset reduces sparc32 to what is required by LEON.
> 
> The defconfig is first adapted to the one used by Gaisler.
> Then the patches removes sun4m and sun4d specific
> implementations such as small drivers, SMP support, IRQ suppor etc.
> 
> Removing sun4m and sun4d support allowed removal of the run time
> patching of the code as well as a lot of assembler code.
> The result is a much cleaner assembler code that is easier to
> understand and thus maintain and extend.
> 
> Changes in v2:
>   - Rebased on top of Andreas' for-next branch
>   - Collected ack's
>   - Added patch to remove cpuid patching (Andreas)
>   - Run-time testing using qemu (Andreas, Mark Cave-Ayland)

Please let me know if you expect me to rebase this on for-next.
I have not yet tried if there are merge conflicts but can take a look in
a some days if required.

That is assuming you agree with the sunset of the sun platforms...

Sam


Re: [PATCH 16/21] drm/atmel-hlcdc: Allow build with COMPILE_TEST=y

2024-04-09 Thread Sam Ravnborg
On Mon, Apr 08, 2024 at 08:04:21PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä 
> 
> Allow atmel-hlcdc to be built with COMPILE_TEST=y for greater
> coverage. Builds fine on x86/x86_64 at least.
> 
> Cc: Sam Ravnborg 
> Cc: Boris Brezillon 
> Signed-off-by: Ville Syrjälä 
Acked-by: Sam Ravnborg 
> ---
>  drivers/gpu/drm/atmel-hlcdc/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/Kconfig 
> b/drivers/gpu/drm/atmel-hlcdc/Kconfig
> index 3bdbab3a6333..945f3aa7bb24 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/Kconfig
> +++ b/drivers/gpu/drm/atmel-hlcdc/Kconfig
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  config DRM_ATMEL_HLCDC
>   tristate "DRM Support for ATMEL HLCDC Display Controller"
> - depends on DRM && OF && COMMON_CLK && MFD_ATMEL_HLCDC && ARM
> + depends on DRM && OF && COMMON_CLK && ((MFD_ATMEL_HLCDC && ARM) || 
> COMPILE_TEST)
>   select DRM_GEM_DMA_HELPER
>   select DRM_KMS_HELPER
>   select DRM_PANEL
> -- 
> 2.43.2


Re: [PATCH v2 2/3] arch: Remove struct fb_info from video helpers

2024-03-28 Thread Sam Ravnborg
Hi Thomas,
On Wed, Mar 27, 2024 at 09:41:30PM +0100, Thomas Zimmermann wrote:
> The per-architecture video helpers do not depend on struct fb_info
> or anything else from fbdev. Remove it from the interface and replace
> fb_is_primary_device() with video_is_primary_device(). The new helper
> is similar in functionality, but can operate on non-fbdev devices.
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: "James E.J. Bottomley" 
> Cc: Helge Deller 
> Cc: "David S. Miller" 
> Cc: Andreas Larsson 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Cc: "H. Peter Anvin" 
Reviewed-by: Sam Ravnborg 


Re: [PATCH v2 1/3] arch: Select fbdev helpers with CONFIG_VIDEO

2024-03-28 Thread Sam Ravnborg
On Wed, Mar 27, 2024 at 09:41:29PM +0100, Thomas Zimmermann wrote:
> Various Kconfig options selected the per-architecture helpers for
> fbdev. But none of the contained code depends on fbdev. Standardize
> on CONFIG_VIDEO, which will allow to add more general helpers for
> video functionality.
> 
> CONFIG_VIDEO protects each architecture's video/ directory. This
> allows for the use of more fine-grained control for each directory's
> files, such as the use of CONFIG_STI_CORE on parisc.
> 
> v2:
> - sparc: rebased onto Makefile changes
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: "James E.J. Bottomley" 
> Cc: Helge Deller 
> Cc: "David S. Miller" 
> Cc: Andreas Larsson 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Cc: "H. Peter Anvin" 

Reviewed-by: Sam Ravnborg 


Re: [PATCH v2 3/3] arch: Rename fbdev header and source files

2024-03-28 Thread Sam Ravnborg
Hi Thomas,

On Wed, Mar 27, 2024 at 09:41:31PM +0100, Thomas Zimmermann wrote:
> The per-architecture fbdev code has no dependencies on fbdev and can
> be used for any video-related subsystem. Rename the files to 'video'.
> Use video-sti.c on parisc as the source file depends on CONFIG_STI_CORE.
> 
> Further update all includes statements, includ guards, and Makefiles.
^ missing 'e' 

> Also update a few strings and comments to refer to video instead of
> fbdev.
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: Vineet Gupta 
> Cc: Catalin Marinas 
> Cc: Will Deacon 
> Cc: Huacai Chen 
> Cc: WANG Xuerui 
> Cc: Geert Uytterhoeven 
> Cc: Thomas Bogendoerfer 
> Cc: "James E.J. Bottomley" 
> Cc: Helge Deller 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Yoshinori Sato 
> Cc: Rich Felker 
> Cc: John Paul Adrian Glaubitz 
> Cc: "David S. Miller" 
> Cc: Andreas Larsson 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Cc: "H. Peter Anvin" 

If the patch is changed to use the Kbuild file to pick the generic
variant of video.h then it is:

Reviewed-by: Sam Ravnborg 

I also added an unrelated sparc comment, that can be addressed another
time.

Sam

> ---
>  arch/arc/include/asm/fb.h|  8 
>  arch/arc/include/asm/video.h |  8 
>  arch/arm/include/asm/fb.h|  6 --
>  arch/arm/include/asm/video.h |  6 ++
>  arch/arm64/include/asm/fb.h  | 10 --
>  arch/arm64/include/asm/video.h   | 10 ++
>  arch/loongarch/include/asm/{fb.h => video.h} |  8 
>  arch/m68k/include/asm/{fb.h => video.h}  |  8 
>  arch/mips/include/asm/{fb.h => video.h}  | 12 ++--
>  arch/parisc/include/asm/{fb.h => video.h}|  8 
>  arch/parisc/video/Makefile   |  2 +-
>  arch/parisc/video/{fbdev.c => video-sti.c}   |  2 +-
>  arch/powerpc/include/asm/{fb.h => video.h}   |  8 
>  arch/powerpc/kernel/pci-common.c |  2 +-
>  arch/sh/include/asm/fb.h |  7 ---
>  arch/sh/include/asm/video.h  |  7 +++
>  arch/sparc/include/asm/{fb.h => video.h} |  8 
>  arch/sparc/video/Makefile|  2 +-
>  arch/sparc/video/{fbdev.c => video.c}|  4 ++--
>  arch/x86/include/asm/{fb.h => video.h}   |  8 
>  arch/x86/video/Makefile  |  2 +-
>  arch/x86/video/{fbdev.c => video.c}  |  3 ++-
>  include/asm-generic/Kbuild   |  2 +-
>  include/asm-generic/{fb.h => video.h}|  6 +++---
>  include/linux/fb.h   |  2 +-
>  25 files changed, 75 insertions(+), 74 deletions(-)
>  delete mode 100644 arch/arc/include/asm/fb.h
>  create mode 100644 arch/arc/include/asm/video.h
>  delete mode 100644 arch/arm/include/asm/fb.h
>  create mode 100644 arch/arm/include/asm/video.h
>  delete mode 100644 arch/arm64/include/asm/fb.h
>  create mode 100644 arch/arm64/include/asm/video.h
>  rename arch/loongarch/include/asm/{fb.h => video.h} (86%)
>  rename arch/m68k/include/asm/{fb.h => video.h} (86%)
>  rename arch/mips/include/asm/{fb.h => video.h} (76%)
>  rename arch/parisc/include/asm/{fb.h => video.h} (68%)
>  rename arch/parisc/video/{fbdev.c => video-sti.c} (96%)
>  rename arch/powerpc/include/asm/{fb.h => video.h} (76%)
>  delete mode 100644 arch/sh/include/asm/fb.h
>  create mode 100644 arch/sh/include/asm/video.h
>  rename arch/sparc/include/asm/{fb.h => video.h} (89%)
>  rename arch/sparc/video/{fbdev.c => video.c} (86%)
>  rename arch/x86/include/asm/{fb.h => video.h} (77%)
>  rename arch/x86/video/{fbdev.c => video.c} (97%)
>  rename include/asm-generic/{fb.h => video.h} (96%)
> 
> diff --git a/arch/arc/include/asm/fb.h b/arch/arc/include/asm/fb.h
> deleted file mode 100644
> index 9c2383d29cbb9..0
> --- a/arch/arc/include/asm/fb.h
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -
> -#ifndef _ASM_FB_H_
> -#define _ASM_FB_H_
> -
> -#include 
> -
> -#endif /* _ASM_FB_H_ */
> diff --git a/arch/arc/include/asm/video.h b/arch/arc/include/asm/video.h
> new file mode 100644
> index 0..8ff7263727fe7
> --- /dev/null
> +++ b/arch/arc/include/asm/video.h
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _ASM_VIDEO_H_
> +#define _ASM_VIDEO_H_
> +
> +#include 
> +
> +#endif /* _ASM_VIDEO_H_ */

arch/arc/include/asm/video.h o

Re: Build regressions/improvements in v6.9-rc1

2024-03-26 Thread Sam Ravnborg
Hi all.

>   + error: arch/sparc/kernel/process_32.o: relocation truncated to fit: 
> R_SPARC_WDISP22 against `.text':  => (.fixup+0xc), (.fixup+0x4)
>   + error: arch/sparc/kernel/signal_32.o: relocation truncated to fit: 
> R_SPARC_WDISP22 against `.text':  => (.fixup+0x18), (.fixup+0x8), 
> (.fixup+0x0), (.fixup+0x20), (.fixup+0x10)
>   + error: relocation truncated to fit: R_SPARC_WDISP22 against `.init.text': 
>  => (.head.text+0x5100), (.head.text+0x5040)
>   + error: relocation truncated to fit: R_SPARC_WDISP22 against symbol 
> `leon_smp_cpu_startup' defined in .text section in 
> arch/sparc/kernel/trampoline_32.o:  => (.init.text+0xa4)

Looks like something is too big for the available space here.
Any hints how to dig into this would be nice.

Note: this is a sparc32 allmodconfig build

Sam


Re: [PATCH] fbdev: Select I/O-memory framebuffer ops for SBus

2024-03-23 Thread Sam Ravnborg
On Fri, Mar 22, 2024 at 09:29:46AM +0100, Thomas Zimmermann wrote:
> Framebuffer I/O on the Sparc Sbus requires read/write helpers for
> I/O memory. Select FB_IOMEM_FOPS accordingly.
> 
> Reported-by: Nick Bowler 
> Closes: 
> https://lore.kernel.org/lkml/5bc21364-41da-a339-676e-5bb0f4fae...@draconx.ca/
> Signed-off-by: Thomas Zimmermann 
> Fixes: 8813e86f6d82 ("fbdev: Remove default file-I/O implementations")
> Cc: Thomas Zimmermann 
> Cc: Javier Martinez Canillas 
> Cc: Daniel Vetter 
> Cc: Helge Deller 
> Cc: Sam Ravnborg 
> Cc: Arnd Bergmann 
> Cc: Geert Uytterhoeven 
> Cc: linux-fb...@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> Cc:  # v6.8+
Reviewed-by: Sam Ravnborg 


Re: [PATCH 3/6] backlight/omap1-bl: Replace FB_BLANK_ states with simple on/off

2024-03-14 Thread Sam Ravnborg
On Thu, Mar 14, 2024 at 09:16:15AM +0100, Thomas Zimmermann wrote:
> Hi
> 
> Am 13.03.24 um 19:00 schrieb Sam Ravnborg:
> > Hi Thomas,
> > 
> > On Wed, Mar 13, 2024 at 04:45:02PM +0100, Thomas Zimmermann wrote:
> > > The backlight is on for fb_blank eq FB_BLANK_UNBLANK, or off for
> > > any other value in fb_blank. But the field fb_blank in struct
> > > backlight_properties is deprecated and should not be used any
> > > longer.
> > > 
> > > Replace the test for fb_blank in omap's backlight code with a
> > > simple boolean parameter and push the test into the update_status
> > > helper. Instead of reading fb_blank directly, decode the backlight
> > > device's status with backlight_is_blank().
> > > 
> > > Signed-off-by: Thomas Zimmermann 
> > My biased opinion is that the approach in this patch is a little bit
> > better:
> > https://lore.kernel.org/lkml/20230107-sam-video-backlight-drop-fb_blank-v1-13-1bd9bafb3...@ravnborg.org/
> > 
> > I never came around resending this series it seems.
> 
> Oh, that series has been around for over a year. I don't care about which
> patches go in as long as they remove the dependency on . I saw
> that Dan has already r-b'ed the current patchset, but if you prefer I'll
> adopt yours.
Whatever works for you. It is trivial stuff and as long as we get it
cleaned up that is fine. You are pushing for this now - so whatever is
easiest for you.

Sam


Re: [PATCH 2/6] backlight/omap1-bl: Remove unused struct omap_backlight_config.set_power

2024-03-13 Thread Sam Ravnborg
On Wed, Mar 13, 2024 at 04:45:01PM +0100, Thomas Zimmermann wrote:
> The callback set_power in struct omap_backlight_config is not
> implemented anywhere. Remove it from the structure and driver.
> 
> Signed-off-by: Thomas Zimmermann 
Reviewed-by: Sam Ravnborg 
> ---
>  drivers/video/backlight/omap1_bl.c | 3 ---
>  include/linux/platform_data/omap1_bl.h | 1 -
>  2 files changed, 4 deletions(-)
> 
> diff --git a/drivers/video/backlight/omap1_bl.c 
> b/drivers/video/backlight/omap1_bl.c
> index 69a49384b3de4..84d148f385951 100644
> --- a/drivers/video/backlight/omap1_bl.c
> +++ b/drivers/video/backlight/omap1_bl.c
> @@ -39,9 +39,6 @@ static inline void omapbl_send_enable(int enable)
>  
>  static void omapbl_blank(struct omap_backlight *bl, int mode)
>  {
> - if (bl->pdata->set_power)
> - bl->pdata->set_power(bl->dev, mode);
> -
>   switch (mode) {
>   case FB_BLANK_NORMAL:
>   case FB_BLANK_VSYNC_SUSPEND:
> diff --git a/include/linux/platform_data/omap1_bl.h 
> b/include/linux/platform_data/omap1_bl.h
> index 5e8b17d77a5fe..3d0bab31a0a94 100644
> --- a/include/linux/platform_data/omap1_bl.h
> +++ b/include/linux/platform_data/omap1_bl.h
> @@ -6,7 +6,6 @@
>  
>  struct omap_backlight_config {
>   int default_intensity;
> - int (*set_power)(struct device *dev, int state);
>  };
>  
>  #endif
> -- 
> 2.44.0


Re: [PATCH 1/6] auxdisplay/ht16k33: Replace use of fb_blank with backlight helper

2024-03-13 Thread Sam Ravnborg
On Wed, Mar 13, 2024 at 04:45:00PM +0100, Thomas Zimmermann wrote:
> Replace the use of struct backlight_properties.fb_blank with a
> call to backlight_get_brightness(). The helper implement the same
> logic as the driver's function.
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: Robin van der Gracht 
> Cc: Miguel Ojeda 

Reviewed-by: Sam Ravnborg 
> ---
>  drivers/auxdisplay/ht16k33.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
> index a90430b7d07ba..83db829b97a5e 100644
> --- a/drivers/auxdisplay/ht16k33.c
> +++ b/drivers/auxdisplay/ht16k33.c
> @@ -314,14 +314,9 @@ static int ht16k33_initialize(struct ht16k33_priv *priv)
>  
>  static int ht16k33_bl_update_status(struct backlight_device *bl)
>  {
> - int brightness = bl->props.brightness;
> + int brightness = backlight_get_brightness(bl);
>   struct ht16k33_priv *priv = bl_get_data(bl);
>  
> - if (bl->props.power != FB_BLANK_UNBLANK ||
> - bl->props.fb_blank != FB_BLANK_UNBLANK ||
> - bl->props.state & BL_CORE_FBBLANK)
> - brightness = 0;
> -
>   return ht16k33_brightness_set(priv, brightness);
>  }
>  
> -- 
> 2.44.0


Re: [PATCH 3/6] backlight/omap1-bl: Replace FB_BLANK_ states with simple on/off

2024-03-13 Thread Sam Ravnborg
Hi Thomas,

On Wed, Mar 13, 2024 at 04:45:02PM +0100, Thomas Zimmermann wrote:
> The backlight is on for fb_blank eq FB_BLANK_UNBLANK, or off for
> any other value in fb_blank. But the field fb_blank in struct
> backlight_properties is deprecated and should not be used any
> longer.
> 
> Replace the test for fb_blank in omap's backlight code with a
> simple boolean parameter and push the test into the update_status
> helper. Instead of reading fb_blank directly, decode the backlight
> device's status with backlight_is_blank().
> 
> Signed-off-by: Thomas Zimmermann 

My biased opinion is that the approach in this patch is a little bit
better:
https://lore.kernel.org/lkml/20230107-sam-video-backlight-drop-fb_blank-v1-13-1bd9bafb3...@ravnborg.org/

I never came around resending this series it seems.

Sam


Re: [PATCH 1/6] auxdisplay/ht16k33: Replace use of fb_blank with backlight helper

2024-03-13 Thread Sam Ravnborg
Hi Miguel.

On Wed, Mar 13, 2024 at 05:08:08PM +0100, Miguel Ojeda wrote:
> Hi Thomas,
> 
> Thanks for this!
> 
> Cc'ing Andy and Geert -- the new maintainer and reviewer.
> 
> Also, a couple quick notes below since I am here...
> 
> On Wed, Mar 13, 2024 at 4:49 PM Thomas Zimmermann  wrote:
> >
> > Replace the use of struct backlight_properties.fb_blank with a
> > call to backlight_get_brightness(). The helper implement the same
> > logic as the driver's function.
> 
> It is not exactly the same logic since `backlight_is_blank` accounts
> for `BL_CORE_SUSPENDED`.

The driver does not set BL_CORE_SUSPENDRESUME so that part is a nop.

Sam


Re: [PATCH v2 28/28] fbdev/p9100: Drop now unused driver p9100

2024-03-11 Thread Sam Ravnborg
Hi Arnd.

On Mon, Mar 11, 2024 at 03:05:25PM +0100, Arnd Bergmann wrote:
> On Sat, Mar 9, 2024, at 19:15, Sam Ravnborg via B4 Relay wrote:
> > From: Sam Ravnborg 
> >
> > The p9100 driver is only relevant for the Sparcbook 3 machine,
> > and with sun4m support removed this driver is no longer relevant.
> >
> > Signed-off-by: Sam Ravnborg 
> > Acked-by: Arnd Bergmann 
> > Acked-by: Thomas Zimmermann 
> > Cc: "David S. Miller" 
> > Cc: Arnd Bergmann 
> > Cc: Andreas Larsson 
> > Cc: Helge Deller 
> > ---
> >  drivers/video/fbdev/Kconfig  |   8 -
> >  drivers/video/fbdev/Makefile |   1 -
> >  drivers/video/fbdev/p9100.c  | 372 
> > ---
> >  3 files changed, 381 deletions(-)
> 
> I tried to figure out if there are other drivers in the same
> category and found the list at
> https://everything2.com/title/Sun+graphics+cards
> 
> As far as I can tell, the only SBUS graphics that were
> shipped on sparc64 are FB_FFB and FB_CG6, so we could
> go further and remove BW2, CG3, TCX, CG14 and LEO as
> well.

Looks like you are right, so we can drop more - good.
As you already wrote - let's get the current patch set processed first.

I did a quick hack on top of my current sparc32 patches.
This is nice reduction of ~2700 lines and 5 fbdev drivers less to care
about.

Sam


[PATCH v3 14/28] sparc32: Drop unused mmu models

2024-03-11 Thread Sam Ravnborg
Drop mmu models not used by LEON, including their header files.
This includes removal of unused includes in various files to fix the
build.

With this change SHMLBA is always PAGE_SIZE so use the
asm-generic variant of shmparam.h for sparc32.
__ARCH_FORCE_SHMLBA is then no longer defined, but
this should be OK if my analysis is correct.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---

Posted v3 here to avoid resending the whole series.
In v3 the asm-generic shmparam.h are introduced and a few
unused variables (reported by kernel test robot) was dropped.

Sam


 arch/sparc/include/asm/mxcc.h| 138 -
 arch/sparc/include/asm/ross.h| 192 ---
 arch/sparc/include/asm/shmparam.h|   2 +-
 arch/sparc/include/asm/shmparam_32.h |  10 -
 arch/sparc/include/asm/swift.h   | 107 
 arch/sparc/include/asm/tsunami.h |  65 ---
 arch/sparc/include/asm/turbosparc.h  | 126 -
 arch/sparc/include/asm/viking.h  | 255 -
 arch/sparc/kernel/entry.S|   1 -
 arch/sparc/mm/Makefile   |   1 -
 arch/sparc/mm/hypersparc.S   | 414 --
 arch/sparc/mm/io-unit.c  |   1 -
 arch/sparc/mm/iommu.c|  31 +-
 arch/sparc/mm/mm_32.h|   1 -
 arch/sparc/mm/srmmu.c| 780 +--
 arch/sparc/mm/swift.S| 256 -
 arch/sparc/mm/tsunami.S  | 132 -
 arch/sparc/mm/viking.S   | 284 --
 18 files changed, 22 insertions(+), 2774 deletions(-)
 delete mode 100644 arch/sparc/include/asm/mxcc.h
 delete mode 100644 arch/sparc/include/asm/ross.h
 delete mode 100644 arch/sparc/include/asm/shmparam_32.h
 delete mode 100644 arch/sparc/include/asm/swift.h
 delete mode 100644 arch/sparc/include/asm/tsunami.h
 delete mode 100644 arch/sparc/include/asm/turbosparc.h
 delete mode 100644 arch/sparc/include/asm/viking.h
 delete mode 100644 arch/sparc/mm/hypersparc.S
 delete mode 100644 arch/sparc/mm/swift.S
 delete mode 100644 arch/sparc/mm/tsunami.S
 delete mode 100644 arch/sparc/mm/viking.S

diff --git a/arch/sparc/include/asm/mxcc.h b/arch/sparc/include/asm/mxcc.h
deleted file mode 100644
index 3a2561bea4dd..
--- a/arch/sparc/include/asm/mxcc.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * mxcc.h:  Definitions of the Viking MXCC registers
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#ifndef _SPARC_MXCC_H
-#define _SPARC_MXCC_H
-
-/* These registers are accessed through ASI 0x2. */
-#define MXCC_DATSTREAM   0x1C0  /* Data stream register */
-#define MXCC_SRCSTREAM   0x1C00100  /* Source stream register */
-#define MXCC_DESSTREAM   0x1C00200  /* Destination stream register */
-#define MXCC_RMCOUNT 0x1C00300  /* Count of references and misses */
-#define MXCC_STEST   0x1C00804  /* Internal self-test */
-#define MXCC_CREG0x1C00A04  /* Control register */
-#define MXCC_SREG0x1C00B00  /* Status register */
-#define MXCC_RREG0x1C00C04  /* Reset register */
-#define MXCC_EREG0x1C00E00  /* Error code register */
-#define MXCC_PREG0x1C00F04  /* Address port register */
-
-/* Some MXCC constants. */
-#define MXCC_STREAM_SIZE 0x20   /* Size in bytes of one stream r/w */
-
-/* The MXCC Control Register:
- *
- * --
- * |   | RRC | RSV |PRE|MCE|PARE|ECE|RSV|
- * --
- *  31  1098-6   5   43   2  1-0
- *
- * RRC: Controls what you read from MXCC_RMCOUNT reg.
- *  0=Misses 1=References
- * PRE: Prefetch enable
- * MCE: Multiple Command Enable
- * PARE: Parity enable
- * ECE: External cache enable
- */
-
-#define MXCC_CTL_RRC   0x0200
-#define MXCC_CTL_PRE   0x0020
-#define MXCC_CTL_MCE   0x0010
-#define MXCC_CTL_PARE  0x0008
-#define MXCC_CTL_ECE   0x0004
-
-/* The MXCC Error Register:
- *
- * 
- * |ME| RSV|CE|PEW|PEE|ASE|EIV| MOPC|ECODE|PRIV|RSV|HPADDR|
- * 
- *  31   30 29  28  27  26  25 24-15  14-7   6  5-3   2-0
- *
- * ME: Multiple Errors have occurred
- * CE: Cache consistency Error
- * PEW: Parity Error during a Write operation
- * PEE: Parity Error involving the External cache
- * ASE: ASynchronous Error
- * EIV: This register is toast
- * MOPC: MXCC Operation Code for instance causing error
- * ECODE: The Error CODE
- * PRIV: A privileged mode error? 0=no 1=yes
- * HPADDR: High PhysicalADDRess bits (35-32)
- */
-
-#define MXCC_ERR_ME 0x8000
-#define MXCC_ERR_CE 0x2000
-#define MXCC_ERR_PEW0x1000
-#define MXCC_ERR_PEE0x0800
-#define MX

Re: [PATCH v2 14/28] sparc32: Drop unused mmu models

2024-03-10 Thread Sam Ravnborg
Hi kernel test robot et al.

On Sun, Mar 10, 2024 at 06:37:53PM +0800, kernel test robot wrote:
> Hi Sam,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on 84b76d05828a1909e20d0f66553b876b801f98c8]
> 
> url:
> https://github.com/intel-lab-lkp/linux/commits/Sam-Ravnborg-via-B4-Relay/sparc32-Update-defconfig-to-LEON-SMP/20240310-021717
> base:   84b76d05828a1909e20d0f66553b876b801f98c8
> patch link:
> https://lore.kernel.org/r/20240309-sunset-v2-14-f09912574d2c%40ravnborg.org
> patch subject: [PATCH v2 14/28] sparc32: Drop unused mmu models
> config: sparc-randconfig-r113-20240310 
> (https://download.01.org/0day-ci/archive/20240310/202403101854.z94sau13-...@intel.com/config)
> compiler: sparc-linux-gcc (GCC) 13.2.0
> reproduce: 
> (https://download.01.org/0day-ci/archive/20240310/202403101854.z94sau13-...@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version 
> of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot 
> | Closes: 
> https://lore.kernel.org/oe-kbuild-all/202403101854.z94sau13-...@intel.com/
> 
> sparse warnings: (new ones prefixed by >>)
> >> arch/sparc/mm/srmmu.c:49:5: sparse: sparse: symbol 'vac_line_size' was not 
> >> declared. Should it be static?
> 
> vim +/vac_line_size +49 arch/sparc/mm/srmmu.c
> 
> accf032cfa582e Sam Ravnborg   2012-05-19  46  
> ^1da177e4c3f41 Linus Torvalds 2005-04-16  47  int vac_cache_size;
> 9d262d95114cf2 Guenter Roeck  2017-04-01  48  EXPORT_SYMBOL(vac_cache_size);
> ^1da177e4c3f41 Linus Torvalds 2005-04-16 @49  int vac_line_size;
> ^1da177e4c3f41 Linus Torvalds 2005-04-16  50  

vac_line_size is no longer used and can be deleted.
vac_cache_size is never written to and can be deleted too.

vac_cache_size is used in shmparam_32.h like this:
#define SHMLBA (vac_cache_size ? vac_cache_size : PAGE_SIZE)

The same file has:
#define __ARCH_FORCE_SHMLBA 1

If I understand it right then when SHMLBA equals PAGE_SIZE then there is
no need to define __ARCH_FORCE_SHMLBA and sparc32 can use the asm-generic
variant of shmparam.h

I will do this change in v3.

Sam


Re: [PATCH v3 2/2] backlight: Add new lm3509 backlight driver

2024-03-10 Thread Sam Ravnborg
Hi Patrick,

a few comments in the following.

Sam

On Sat, Mar 09, 2024 at 02:24:56PM +0100, Patrick Gansterer wrote:
> This is a general driver for LM3509 backlight chip of TI.
> LM3509 is High Efficiency Boost for White LEDs and/or OLED Displays with
> Dual Current Sinks. This driver supports OLED/White LED select, brightness
> control and sub/main control.
> The datasheet can be found at http://www.ti.com/product/lm3509.
> 
> Signed-off-by: Patrick Gansterer 
> ---
>  drivers/video/backlight/Kconfig |   7 +
>  drivers/video/backlight/Makefile|   1 +
>  drivers/video/backlight/lm3509_bl.c | 340 
>  3 files changed, 348 insertions(+)
>  create mode 100644 drivers/video/backlight/lm3509_bl.c
> 
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index ea2d0d69bd8c..96ad5dc584b6 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
> @@ -366,6 +366,13 @@ config BACKLIGHT_AAT2870
> If you have a AnalogicTech AAT2870 say Y to enable the
> backlight driver.
>  
> +config BACKLIGHT_LM3509
> + tristate "Backlight Driver for LM3509"
> + depends on I2C
> + select REGMAP_I2C
> + help
> +   This supports TI LM3509 Backlight Driver
> +
>  config BACKLIGHT_LM3630A
>   tristate "Backlight Driver for LM3630A"
>   depends on I2C && PWM
> diff --git a/drivers/video/backlight/Makefile 
> b/drivers/video/backlight/Makefile
> index 06966cb20459..51a4ac5d0530 100644
> --- a/drivers/video/backlight/Makefile
> +++ b/drivers/video/backlight/Makefile
> @@ -35,6 +35,7 @@ obj-$(CONFIG_BACKLIGHT_HP700)   += 
> jornada720_bl.o
>  obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)   += ipaq_micro_bl.o
>  obj-$(CONFIG_BACKLIGHT_KTD253)   += ktd253-backlight.o
>  obj-$(CONFIG_BACKLIGHT_KTZ8866)  += ktz8866.o
> +obj-$(CONFIG_BACKLIGHT_LM3509)   += lm3509_bl.o
>  obj-$(CONFIG_BACKLIGHT_LM3533)   += lm3533_bl.o
>  obj-$(CONFIG_BACKLIGHT_LM3630A)  += lm3630a_bl.o
>  obj-$(CONFIG_BACKLIGHT_LM3639)   += lm3639_bl.o
> diff --git a/drivers/video/backlight/lm3509_bl.c 
> b/drivers/video/backlight/lm3509_bl.c
> new file mode 100644
> index ..bfad0aaffa0d
> --- /dev/null
> +++ b/drivers/video/backlight/lm3509_bl.c
> @@ -0,0 +1,340 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define LM3509_NAME "lm3509_bl"
> +
> +#define LM3509_SINK_MAIN 0
> +#define LM3509_SINK_SUB 1
> +#define LM3509_NUM_SINKS 2
> +
> +#define LM3509_DEF_BRIGHTNESS 0x12
> +#define LM3509_MAX_BRIGHTNESS 0x1F
> +
> +#define REG_GP 0x10
> +#define REG_BMAIN 0xA0
> +#define REG_BSUB 0xB0
> +#define REG_MAX 0xFF
> +
> +enum {
> + REG_GP_ENM_BIT = 0,
> + REG_GP_ENS_BIT,
> + REG_GP_UNI_BIT,
> + REG_GP_RMP0_BIT,
> + REG_GP_RMP1_BIT,
> + REG_GP_OLED_BIT,
> +};
> +
> +struct lm3509_bl {
> + struct regmap *regmap;
> + struct backlight_device *bl_main;
> + struct backlight_device *bl_sub;
> + struct gpio_desc *reset_gpio;
> +};
> +
> +struct lm3509_bl_led_pdata {
> + const char *label;
> + int led_sources;
> + u32 brightness;
> + u32 max_brightness;
> +};
> +
> +static void lm3509_reset(struct lm3509_bl *data)
> +{
> + if (data->reset_gpio) {
> + gpiod_set_value(data->reset_gpio, 1);
> + udelay(1);
> + gpiod_set_value(data->reset_gpio, 0);
> + udelay(10);
> + }
> +}
> +
> +static int lm3509_update_status(struct backlight_device *bl,
> + unsigned int en_mask, unsigned int br_reg)
> +{
> + struct lm3509_bl *data = bl_get_data(bl);
> + int ret;
> + bool en;
> +
> + ret = regmap_write(data->regmap, br_reg, bl->props.brightness);

Here you can use backlight_get_brightness() thus avoiding direct access
to backlight internal properties.

> + if (ret < 0)
> + return ret;
> +
> + en = bl->props.power <= FB_BLANK_NORMAL;
Use backlight_is_blank() here.

Sam



> + return regmap_update_bits(data->regmap, REG_GP, en_mask,
> +   en ? en_mask : 0);
> +}
> +
> +static int lm3509_main_update_status(struct backlight_device *bl)
> +{
> + return lm3509_update_status(bl, BIT(REG_GP_ENM_BIT), REG_BMAIN);
> +}
> +
> +static const struct backlight_ops lm3509_main_ops = {
> + .options = BL_CORE_SUSPENDRESUME,
> + .update_status = lm3509_main_update_status,
> +};
> +
> +static int lm3509_sub_update_status(struct backlight_device *bl)
> +{
> + return lm3509_update_status(bl, BIT(REG_GP_ENS_BIT), REG_BSUB);
> +}
> +
> +static const struct backlight_ops lm3509_sub_ops = {
> + .options = BL_CORE_SUSPENDRESUME,
> + .update_status = lm3509_sub_update_status,
> +};
> +
> +static struct backlight_device *
> +lm3509_backlight_register(struct device *dev, const char 

[PATCH v2 14/28] sparc32: Drop unused mmu models

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop mmu models not used by LEON, including their header files.
This includes removal of unused includes in various files to fix the
build.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/mxcc.h   | 138 ---
 arch/sparc/include/asm/ross.h   | 192 -
 arch/sparc/include/asm/swift.h  | 107 -
 arch/sparc/include/asm/tsunami.h|  65 ---
 arch/sparc/include/asm/turbosparc.h | 126 --
 arch/sparc/include/asm/viking.h | 255 
 arch/sparc/kernel/entry.S   |   1 -
 arch/sparc/mm/Makefile  |   1 -
 arch/sparc/mm/hypersparc.S  | 414 ---
 arch/sparc/mm/io-unit.c |   1 -
 arch/sparc/mm/iommu.c   |  31 +-
 arch/sparc/mm/mm_32.h   |   1 -
 arch/sparc/mm/srmmu.c   | 776 +---
 arch/sparc/mm/swift.S   | 256 
 arch/sparc/mm/tsunami.S | 132 --
 arch/sparc/mm/viking.S  | 284 -
 16 files changed, 21 insertions(+), 2759 deletions(-)

diff --git a/arch/sparc/include/asm/mxcc.h b/arch/sparc/include/asm/mxcc.h
deleted file mode 100644
index 3a2561bea4dd..
--- a/arch/sparc/include/asm/mxcc.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * mxcc.h:  Definitions of the Viking MXCC registers
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#ifndef _SPARC_MXCC_H
-#define _SPARC_MXCC_H
-
-/* These registers are accessed through ASI 0x2. */
-#define MXCC_DATSTREAM   0x1C0  /* Data stream register */
-#define MXCC_SRCSTREAM   0x1C00100  /* Source stream register */
-#define MXCC_DESSTREAM   0x1C00200  /* Destination stream register */
-#define MXCC_RMCOUNT 0x1C00300  /* Count of references and misses */
-#define MXCC_STEST   0x1C00804  /* Internal self-test */
-#define MXCC_CREG0x1C00A04  /* Control register */
-#define MXCC_SREG0x1C00B00  /* Status register */
-#define MXCC_RREG0x1C00C04  /* Reset register */
-#define MXCC_EREG0x1C00E00  /* Error code register */
-#define MXCC_PREG0x1C00F04  /* Address port register */
-
-/* Some MXCC constants. */
-#define MXCC_STREAM_SIZE 0x20   /* Size in bytes of one stream r/w */
-
-/* The MXCC Control Register:
- *
- * --
- * |   | RRC | RSV |PRE|MCE|PARE|ECE|RSV|
- * --
- *  31  1098-6   5   43   2  1-0
- *
- * RRC: Controls what you read from MXCC_RMCOUNT reg.
- *  0=Misses 1=References
- * PRE: Prefetch enable
- * MCE: Multiple Command Enable
- * PARE: Parity enable
- * ECE: External cache enable
- */
-
-#define MXCC_CTL_RRC   0x0200
-#define MXCC_CTL_PRE   0x0020
-#define MXCC_CTL_MCE   0x0010
-#define MXCC_CTL_PARE  0x0008
-#define MXCC_CTL_ECE   0x0004
-
-/* The MXCC Error Register:
- *
- * 
- * |ME| RSV|CE|PEW|PEE|ASE|EIV| MOPC|ECODE|PRIV|RSV|HPADDR|
- * 
- *  31   30 29  28  27  26  25 24-15  14-7   6  5-3   2-0
- *
- * ME: Multiple Errors have occurred
- * CE: Cache consistency Error
- * PEW: Parity Error during a Write operation
- * PEE: Parity Error involving the External cache
- * ASE: ASynchronous Error
- * EIV: This register is toast
- * MOPC: MXCC Operation Code for instance causing error
- * ECODE: The Error CODE
- * PRIV: A privileged mode error? 0=no 1=yes
- * HPADDR: High PhysicalADDRess bits (35-32)
- */
-
-#define MXCC_ERR_ME 0x8000
-#define MXCC_ERR_CE 0x2000
-#define MXCC_ERR_PEW0x1000
-#define MXCC_ERR_PEE0x0800
-#define MXCC_ERR_ASE0x0400
-#define MXCC_ERR_EIV0x0200
-#define MXCC_ERR_MOPC   0x01FF8000
-#define MXCC_ERR_ECODE  0x7F80
-#define MXCC_ERR_PRIV   0x0040
-#define MXCC_ERR_HPADDR 0x000f
-
-/* The MXCC Port register:
- *
- * -
- * || MID ||
- * -
- *  3121 20-18 17 0
- *
- * MID: The moduleID of the cpu your read this from.
- */
-
-#ifndef __ASSEMBLY__
-
-static inline void mxcc_set_stream_src(unsigned long *paddr)
-{
-   unsigned long data0 = paddr[0];
-   unsigned long data1 = paddr[1];
-
-   __asm__ __volatile__ ("or %%g0, %0, %%g2\n\t"
- "or %%g0, %1, %%g3\n\t"
- "stda %%g2, [%2] %3\n\t" : :
- "r" (data0), "r"

[PATCH v2 10/28] sparc32: Drop sun4d/sun4m smp support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the sun4m and sun4d smp support code.

The sparc32 kernel will not boot unless this is a LEON system,
so drop checks for other systems as they will not trigger.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/Makefile|   2 +-
 arch/sparc/kernel/kernel.h|  18 --
 arch/sparc/kernel/smp_32.c| 102 +--
 arch/sparc/kernel/sun4d_smp.c | 408 --
 arch/sparc/kernel/sun4m_smp.c | 275 
 arch/sparc/mm/srmmu.c |  10 +-
 6 files changed, 8 insertions(+), 807 deletions(-)

diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index d3d21e58b4e6..bd31bdd0b13e 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -79,7 +79,7 @@ obj-$(CONFIG_SPARC_GRPCI2)+= leon_pci_grpci2.o
 obj-$(CONFIG_SPARC_GRPCI1)+= leon_pci_grpci1.o
 
 obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o
-obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
+obj-$(CONFIG_SPARC32_SMP) += leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
 obj-$(CONFIG_SPARC64) += auxio_64.o
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index c467b1425506..621fb7b6ec64 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -96,24 +96,6 @@ void unexpected_irq(int irq, void *dev_id, struct pt_regs * 
regs);
 void sun4m_unmask_profile_irq(void);
 void sun4m_clear_profile_irq(int cpu);
 
-/* sun4m_smp.c */
-void sun4m_cpu_pre_starting(void *arg);
-void sun4m_cpu_pre_online(void *arg);
-void __init smp4m_boot_cpus(void);
-int smp4m_boot_one_cpu(int i, struct task_struct *idle);
-void __init smp4m_smp_done(void);
-void smp4m_cross_call_irq(void);
-void smp4m_percpu_timer_interrupt(struct pt_regs *regs);
-
-/* sun4d_smp.c */
-void sun4d_cpu_pre_starting(void *arg);
-void sun4d_cpu_pre_online(void *arg);
-void __init smp4d_boot_cpus(void);
-int smp4d_boot_one_cpu(int i, struct task_struct *idle);
-void __init smp4d_smp_done(void);
-void smp4d_cross_call_irq(void);
-void smp4d_percpu_timer_interrupt(struct pt_regs *regs);
-
 /* leon_smp.c */
 void leon_cpu_pre_starting(void *arg);
 void leon_cpu_pre_online(void *arg);
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 87eaa7719fa2..42fb90577a82 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -87,29 +87,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
num, bogosum/(50/HZ),
(bogosum/(5000/HZ))%100);
 
-   switch(sparc_cpu_model) {
-   case sun4m:
-   smp4m_smp_done();
-   break;
-   case sun4d:
-   smp4d_smp_done();
-   break;
-   case sparc_leon:
-   leon_smp_done();
-   break;
-   case sun4e:
-   printk("SUN4E\n");
-   BUG();
-   break;
-   case sun4u:
-   printk("SUN4U\n");
-   BUG();
-   break;
-   default:
-   printk("UNKNOWN!\n");
-   BUG();
-   break;
-   }
+   leon_smp_done();
 }
 
 void cpu_panic(void)
@@ -191,29 +169,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 
smp_store_cpu_info(boot_cpu_id);
 
-   switch(sparc_cpu_model) {
-   case sun4m:
-   smp4m_boot_cpus();
-   break;
-   case sun4d:
-   smp4d_boot_cpus();
-   break;
-   case sparc_leon:
-   leon_boot_cpus();
-   break;
-   case sun4e:
-   printk("SUN4E\n");
-   BUG();
-   break;
-   case sun4u:
-   printk("SUN4U\n");
-   BUG();
-   break;
-   default:
-   printk("UNKNOWN!\n");
-   BUG();
-   break;
-   }
+   leon_boot_cpus();
 }
 
 /* Set this up early so that things like the scheduler can init
@@ -252,31 +208,7 @@ void __init smp_prepare_boot_cpu(void)
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
-   int ret=0;
-
-   switch(sparc_cpu_model) {
-   case sun4m:
-   ret = smp4m_boot_one_cpu(cpu, tidle);
-   break;
-   case sun4d:
-   ret = smp4d_boot_one_cpu(cpu, tidle);
-   break;
-   case sparc_leon:
-   ret = leon_boot_one_cpu(cpu, tidle);
-   break;
-   case sun4e:
-   printk("SUN4E\n");
-   BUG();
-   break;
-   case sun4u:
-   printk("SUN4U\n");
-   BUG();
-   break;
-   default:
-   printk("UNKNOWN!\n");
-   BUG();
-   break;
-   }
+   int ret = leon_boot_one_cpu(cpu, ti

[PATCH v2 09/28] sparc32: Drop sun4m/sun4d specific irq handling

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Some of the sun4m irq infrastructure is used by LEON too,
so keep that and drop the rest.
The patch include a few extra fixes fix the build after
the removal of the irq support.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/irq_32.h |   2 -
 arch/sparc/kernel/Makefile  |   2 +-
 arch/sparc/kernel/irq_32.c  |  30 +--
 arch/sparc/kernel/kernel.h  |  13 --
 arch/sparc/kernel/sun4d_irq.c   | 494 
 arch/sparc/kernel/sun4d_smp.c   |   4 -
 arch/sparc/kernel/sun4m_irq.c   | 240 ---
 arch/sparc/mm/io-unit.c |   2 -
 8 files changed, 2 insertions(+), 785 deletions(-)

diff --git a/arch/sparc/include/asm/irq_32.h b/arch/sparc/include/asm/irq_32.h
index 6ee48321cbc2..c402c81b85a7 100644
--- a/arch/sparc/include/asm/irq_32.h
+++ b/arch/sparc/include/asm/irq_32.h
@@ -17,8 +17,6 @@
 
 #define irq_canonicalize(irq)  (irq)
 
-void __init sun4d_init_sbi_irq(void);
-
 #define NO_IRQ 0x
 
 #endif
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index b253b7e132ce..d3d21e58b4e6 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -28,7 +28,7 @@ obj-y   += traps_$(BITS).o
 
 # IRQ
 obj-y   += irq_$(BITS).o
-obj-$(CONFIG_SPARC32)   += sun4m_irq.o sun4d_irq.o
+obj-$(CONFIG_SPARC32)   += sun4m_irq.o
 
 obj-y   += process_$(BITS).o
 obj-y   += process.o
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index 510184c3aa17..135170f362c1 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -235,36 +235,8 @@ void handler_irq(unsigned int pil, struct pt_regs *regs)
set_irq_regs(old_regs);
 }
 
-/* djhr
- * This could probably be made indirect too and assigned in the CPU
- * bits of the code. That would be much nicer I think and would also
- * fit in with the idea of being able to tune your kernel for your machine
- * by removing unrequired machine and device support.
- *
- */
-
 void __init init_IRQ(void)
 {
-   switch (sparc_cpu_model) {
-   case sun4m:
-   pcic_probe();
-   if (pcic_present())
-   sun4m_pci_init_IRQ();
-   else
-   sun4m_init_IRQ();
-   break;
-
-   case sun4d:
-   sun4d_init_IRQ();
-   break;
-
-   case sparc_leon:
-   leon_init_IRQ();
-   break;
-
-   default:
-   prom_printf("Cannot initialize IRQs on this Sun machine...");
-   break;
-   }
+   leon_init_IRQ();
 }
 
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 6165e1b26df7..c467b1425506 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -93,7 +93,6 @@ extern spinlock_t irq_action_lock;
 void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs);
 
 /* sun4m_irq.c */
-void sun4m_init_IRQ(void);
 void sun4m_unmask_profile_irq(void);
 void sun4m_clear_profile_irq(int cpu);
 
@@ -106,18 +105,6 @@ void __init smp4m_smp_done(void);
 void smp4m_cross_call_irq(void);
 void smp4m_percpu_timer_interrupt(struct pt_regs *regs);
 
-/* sun4d_irq.c */
-extern spinlock_t sun4d_imsk_lock;
-
-void sun4d_init_IRQ(void);
-int sun4d_request_irq(unsigned int irq,
-  irq_handler_t handler,
-  unsigned long irqflags,
-  const char *devname, void *dev_id);
-int show_sun4d_interrupts(struct seq_file *, void *);
-void sun4d_distribute_irqs(void);
-void sun4d_free_irq(unsigned int irq, void *dev_id);
-
 /* sun4d_smp.c */
 void sun4d_cpu_pre_starting(void *arg);
 void sun4d_cpu_pre_online(void *arg);
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
deleted file mode 100644
index 7140cff04b54..
--- a/arch/sparc/kernel/sun4d_irq.c
+++ /dev/null
@@ -1,494 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * SS1000/SC2000 interrupt handling.
- *
- *  Copyright (C) 1997,1998 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
- *  Heavily based on arch/sparc/kernel/irq.c.
- */
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "kernel.h"
-#include "irq.h"
-
-/* Sun4d interrupts fall roughly into two categories.  SBUS and
- * cpu local.  CPU local interrupts cover the timer interrupts
- * and whatnot, and we encode those as normal PILs between
- * 0 and 15.
- * SBUS interrupts are encodes as a combination of board, level and slot.
- */
-
-struct sun4d_handler_data {
-   unsigned int cpuid;/* target cpu */
-   unsigned int real_irq; /* interrupt level */
-};
-
-
-static unsigned int sun4d_encode_irq(int board, int lvl, int slot)
-{
-   return (board + 1

[PATCH v2 27/28] sbus: char: Drop now unused uctrl driver

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The uctrl driver is only relevant for the Sparcbook 3 machine,
and with sun4m support removed this driver is no logner relevant.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 drivers/sbus/char/Kconfig  |   8 -
 drivers/sbus/char/Makefile |   1 -
 drivers/sbus/char/uctrl.c  | 434 -
 3 files changed, 443 deletions(-)

diff --git a/drivers/sbus/char/Kconfig b/drivers/sbus/char/Kconfig
index 7c0a308e4959..8b80abc554ed 100644
--- a/drivers/sbus/char/Kconfig
+++ b/drivers/sbus/char/Kconfig
@@ -21,14 +21,6 @@ config OBP_FLASH
  The OpenBoot PROM on Ultra systems is flashable. If you want to be
  able to upgrade the OBP firmware, say Y here.
 
-config TADPOLE_TS102_UCTRL
-   tristate "Tadpole TS102 Microcontroller support"
-   help
- Say Y here to directly support the TS102 Microcontroller interface
- on the Tadpole Sparcbook 3.  This device handles power-management
- events, and can also notice the attachment/detachment of external
- monitors and mice.
-
 config BBC_I2C
tristate "UltraSPARC-III bootbus i2c controller driver"
depends on PCI && SPARC64
diff --git a/drivers/sbus/char/Makefile b/drivers/sbus/char/Makefile
index 44347c918f6b..9db2faabfae8 100644
--- a/drivers/sbus/char/Makefile
+++ b/drivers/sbus/char/Makefile
@@ -14,6 +14,5 @@ obj-$(CONFIG_ENVCTRL) += envctrl.o
 obj-$(CONFIG_DISPLAY7SEG)  += display7seg.o
 obj-$(CONFIG_OBP_FLASH)+= flash.o
 obj-$(CONFIG_SUN_OPENPROMIO)   += openprom.o
-obj-$(CONFIG_TADPOLE_TS102_UCTRL)  += uctrl.o
 obj-$(CONFIG_BBC_I2C)  += bbc.o
 obj-$(CONFIG_ORACLE_DAX)   += oradax.o
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c
deleted file mode 100644
index cf15a4186d03..
--- a/drivers/sbus/char/uctrl.c
+++ /dev/null
@@ -1,434 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* uctrl.c: TS102 Microcontroller interface on Tadpole Sparcbook 3
- *
- * Copyright 1999 Derrick J Brashear (sha...@dementia.org)
- * Copyright 2008 David S. Miller (da...@davemloft.net)
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#define DEBUG 1
-#ifdef DEBUG
-#define dprintk(x) printk x
-#else
-#define dprintk(x)
-#endif
-
-struct uctrl_regs {
-   u32 uctrl_intr;
-   u32 uctrl_data;
-   u32 uctrl_stat;
-   u32 uctrl_xxx[5];
-};
-
-struct ts102_regs {
-   u32 card_a_intr;
-   u32 card_a_stat;
-   u32 card_a_ctrl;
-   u32 card_a_xxx;
-   u32 card_b_intr;
-   u32 card_b_stat;
-   u32 card_b_ctrl;
-   u32 card_b_xxx;
-   u32 uctrl_intr;
-   u32 uctrl_data;
-   u32 uctrl_stat;
-   u32 uctrl_xxx;
-   u32 ts102_xxx[4];
-};
-
-/* Bits for uctrl_intr register */
-#define UCTRL_INTR_TXE_REQ 0x01/* transmit FIFO empty int req */
-#define UCTRL_INTR_TXNF_REQ0x02/* transmit FIFO not full int req */
-#define UCTRL_INTR_RXNE_REQ0x04/* receive FIFO not empty int req */
-#define UCTRL_INTR_RXO_REQ 0x08/* receive FIFO overflow int req */
-#define UCTRL_INTR_TXE_MSK 0x10/* transmit FIFO empty mask */
-#define UCTRL_INTR_TXNF_MSK0x20/* transmit FIFO not full mask */
-#define UCTRL_INTR_RXNE_MSK0x40/* receive FIFO not empty mask */
-#define UCTRL_INTR_RXO_MSK 0x80/* receive FIFO overflow mask */
-
-/* Bits for uctrl_stat register */
-#define UCTRL_STAT_TXE_STA 0x01/* transmit FIFO empty status */
-#define UCTRL_STAT_TXNF_STA0x02/* transmit FIFO not full status */
-#define UCTRL_STAT_RXNE_STA0x04/* receive FIFO not empty status */
-#define UCTRL_STAT_RXO_STA 0x08/* receive FIFO overflow status */
-
-static DEFINE_MUTEX(uctrl_mutex);
-static const char *uctrl_extstatus[16] = {
-"main power available",
-"internal battery attached",
-"external battery attached",
-"external VGA attached",
-"external keyboard attached",
-"external mouse attached",
-"lid down",
-"internal battery currently charging",
-"external battery currently charging",
-"internal battery currently discharging",
-"external battery currently discharging",
-};
-
-/* Everything required for one transaction with the uctrl */
-struct uctrl_txn {
-   u8 opcode;
-   u8 inbits;
-   u8 outbits;
-   u8 *inbuf;
-   u8 *outbuf;
-};
-
-struct uctrl_status {
-   u8 current_temp; /* 0x07 */
-   u8 reset_status; /* 0x0b */
-   u16 event_sta

[PATCH v2 21/28] sparc32: Drop unused prom ranges support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop support for prom ranges - not used anymore.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/oplib_32.h |  11 
 arch/sparc/prom/Makefile  |   1 -
 arch/sparc/prom/init_32.c |   2 -
 arch/sparc/prom/ranges.c  | 114 --
 4 files changed, 128 deletions(-)

diff --git a/arch/sparc/include/asm/oplib_32.h 
b/arch/sparc/include/asm/oplib_32.h
index d1cf3a27a40d..4ef7f05978d3 100644
--- a/arch/sparc/include/asm/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
@@ -163,17 +163,6 @@ int prom_setprop(phandle node, const char *prop_name, char 
*prop_value,
 
 phandle prom_inst2pkg(int);
 
-/* Dorking with Bus ranges... */
-
-/* Apply promlib probes OBIO ranges to registers. */
-void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
-
-/* Apply ranges of any prom node (and optionally parent node as well) to 
registers. */
-void prom_apply_generic_ranges(phandle node, phandle parent,
-  struct linux_prom_registers *sbusregs, int 
nregs);
-
-void prom_ranges_init(void);
-
 /* CPU probing helpers.  */
 int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
 int cpu_find_by_mid(int mid, phandle *prom_node);
diff --git a/arch/sparc/prom/Makefile b/arch/sparc/prom/Makefile
index a1adc75d8055..0be170eeb57a 100644
--- a/arch/sparc/prom/Makefile
+++ b/arch/sparc/prom/Makefile
@@ -9,7 +9,6 @@ lib-y += init_$(BITS).o
 lib-$(CONFIG_SPARC32) += memory.o
 lib-y += misc_$(BITS).o
 lib-$(CONFIG_SPARC32) += mp.o
-lib-$(CONFIG_SPARC32) += ranges.o
 lib-y += console_$(BITS).o
 lib-y += printf.o
 lib-y += tree_$(BITS).o
diff --git a/arch/sparc/prom/init_32.c b/arch/sparc/prom/init_32.c
index d20470166cb1..1681f1f980d4 100644
--- a/arch/sparc/prom/init_32.c
+++ b/arch/sparc/prom/init_32.c
@@ -67,8 +67,6 @@ void __init prom_init(struct linux_romvec *rp)
 
prom_meminit();
 
-   prom_ranges_init();
-
printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
   romvec->pv_romvers, prom_rev);
 
diff --git a/arch/sparc/prom/ranges.c b/arch/sparc/prom/ranges.c
deleted file mode 100644
index 20cb828bc5f4..
--- a/arch/sparc/prom/ranges.c
+++ /dev/null
@@ -1,114 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * ranges.c: Handle ranges in newer proms for obio/sbus.
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- * Copyright (C) 1997 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
- */
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-static struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX];
-static int num_obio_ranges;
-
-/* Adjust register values based upon the ranges parameters. */
-static void prom_adjust_regs(struct linux_prom_registers *regp, int nregs,
-struct linux_prom_ranges *rangep, int nranges)
-{
-   int regc, rngc;
-
-   for (regc = 0; regc < nregs; regc++) {
-   for (rngc = 0; rngc < nranges; rngc++)
-   if (regp[regc].which_io == rangep[rngc].ot_child_space)
-   break; /* Fount it */
-   if (rngc == nranges) /* oops */
-   prom_printf("adjust_regs: Could not find range with 
matching bus type...\n");
-   regp[regc].which_io = rangep[rngc].ot_parent_space;
-   regp[regc].phys_addr -= rangep[rngc].ot_child_base;
-   regp[regc].phys_addr += rangep[rngc].ot_parent_base;
-   }
-}
-
-static void prom_adjust_ranges(struct linux_prom_ranges *ranges1, int nranges1,
-  struct linux_prom_ranges *ranges2, int nranges2)
-{
-   int rng1c, rng2c;
-
-   for (rng1c = 0; rng1c < nranges1; rng1c++) {
-   for (rng2c = 0; rng2c < nranges2; rng2c++)
-   if (ranges1[rng1c].ot_parent_space == 
ranges2[rng2c].ot_child_space &&
-  ranges1[rng1c].ot_parent_base >= 
ranges2[rng2c].ot_child_base &&
-  ranges2[rng2c].ot_child_base + 
ranges2[rng2c].or_size - ranges1[rng1c].ot_parent_base > 0U)
-   break;
-   if (rng2c == nranges2) /* oops */
-   prom_printf("adjust_ranges: Could not find matching bus 
type...\n");
-   else if (ranges1[rng1c].ot_parent_base + ranges1[rng1c].or_size 
> ranges2[rng2c].ot_child_base + ranges2[rng2c].or_size)
-   ranges1[rng1c].or_size = ranges2[rng2c].ot_child_base + 
ranges2[rng2c].or_size - ranges1[rng1c].ot_parent_base;
-   ranges1[rng1c].ot_parent_space = ranges2[rng2c].ot_parent_space;
-   ranges1[rng1c].ot_parent_base += ranges2[rng2c].ot_parent_base;
-   

[PATCH v2 19/28] sparc32: Drop support for 7 register windows

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Some older SPARC CPUs had support for only 7 register windows.
To support this run-time patching was used.

LEON demand 8 register windows for use with Linux so
there is no need to support the 7 window configuration.

The complexity of the assembler code is reduced
when dropping the run-time patching, thus increasing
the maintainability.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/switch_to_32.h |  1 -
 arch/sparc/kernel/entry.S | 28 ---
 arch/sparc/kernel/etrap_32.S  | 35 +--
 arch/sparc/kernel/head_32.S   | 65 ---
 arch/sparc/kernel/rtrap_32.S  | 55 +
 arch/sparc/kernel/wof.S   | 43 ---
 arch/sparc/kernel/wuf.S   | 20 +++
 7 files changed, 57 insertions(+), 190 deletions(-)

diff --git a/arch/sparc/include/asm/switch_to_32.h 
b/arch/sparc/include/asm/switch_to_32.h
index 42eeafcb8a41..7aaaf31c09b4 100644
--- a/arch/sparc/include/asm/switch_to_32.h
+++ b/arch/sparc/include/asm/switch_to_32.h
@@ -37,7 +37,6 @@ extern struct thread_info *current_set[NR_CPUS];
 
 #define prepare_arch_switch(next) do { \
__asm__ __volatile__( \
-   ".globl\tflush_patch_switch\nflush_patch_switch:\n\t" \
"save %sp, -0x40, %sp; save %sp, -0x40, %sp; save %sp, -0x40, %sp\n\t" \
"save %sp, -0x40, %sp; save %sp, -0x40, %sp; save %sp, -0x40, %sp\n\t" \
"save %sp, -0x40, %sp\n\t" \
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 18c67b4fb017..ea51a17ac3fc 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -384,11 +384,8 @@ do_flush_windows:
 
RESTORE_ALL
 
-   .globl  flush_patch_one
-
/* We get these for debugging routines using __builtin_return_address() 
*/
 dfw_kernel:
-flush_patch_one:
FLUSH_ALL_KERNEL_WINDOWS
 
/* Advance over the trap instruction. */
@@ -558,10 +555,9 @@ sys_rt_sigreturn:
 * XXX code just like on sparc64... -DaveM
 */
.align  4
-   .globl  sys_fork, flush_patch_two
+   .globl  sys_fork
 sys_fork:
mov %o7, %l5
-flush_patch_two:
FLUSH_ALL_KERNEL_WINDOWS;
ld  [%curptr + TI_TASK], %o4
rd  %psr, %g4
@@ -574,10 +570,9 @@ flush_patch_two:
 mov%l5, %o7
 
/* Whee, kernel threads! */
-   .globl  sys_clone, flush_patch_three
+   .globl  sys_clone
 sys_clone:
mov %o7, %l5
-flush_patch_three:
FLUSH_ALL_KERNEL_WINDOWS;
ld  [%curptr + TI_TASK], %o4
rd  %psr, %g4
@@ -590,9 +585,8 @@ flush_patch_three:
 mov%l5, %o7
 
/* Whee, real vfork! */
-   .globl  sys_vfork, flush_patch_four
+   .globl  sys_vfork
 sys_vfork:
-flush_patch_four:
FLUSH_ALL_KERNEL_WINDOWS;
ld  [%curptr + TI_TASK], %o4
rd  %psr, %g4
@@ -909,17 +903,7 @@ breakpoint_trap:
 #endif
 
.align  4
-   .globl  flush_patch_exception
-flush_patch_exception:
-   FLUSH_ALL_KERNEL_WINDOWS;
-   ldd [%o0], %o6
-   jmpl%o7 + 0xc, %g0  ! see asm-sparc/processor.h
-mov1, %g1  ! signal EFAULT condition
-
-   .align  4
-   .globl  kill_user_windows, kuw_patch1_7win
-   .globl  kuw_patch1
-kuw_patch1_7win:   sll %o3, 6, %o3
+   .globl  kill_user_windows
 
/* No matter how much overhead this routine has in the worst
 * case scenario, it is several times better than taking the
@@ -939,11 +923,11 @@ kill_user_windows:
be  4f  ! yep, we are done
 rd %wim, %o3   ! get current wim
srl %o3, 1, %o4 ! simulate a save
-kuw_patch1:
+kuw_next:
sll %o3, 7, %o3 ! compute next wim
or  %o4, %o3, %o3   ! result
andncc  %o0, %o3, %o0   ! clean this bit in umask
-   bne kuw_patch1  ! not done yet
+   bne kuw_next! not done yet
 srl%o3, 1, %o4 ! begin another save simulation
wr  %o3, 0x0, %wim  ! set the new wim
st  %g0, [%g6 + TI_UWINMASK]! clear uwinmask
diff --git a/arch/sparc/kernel/etrap_32.S b/arch/sparc/kernel/etrap_32.S
index bb222459f097..95dfdea1f36c 100644
--- a/arch/sparc/kernel/etrap_32.S
+++ b/arch/sparc/kernel/etrap_32.S
@@ -30,18 +30,6 @@
.text
.align 4
 
-   /* SEVEN WINDOW PATCH INSTRUCTIONS */
-   .globl  tsetup_7win_patch1, tsetup_7win_patch2
-   .globl  tsetup_7win_patch3, tsetup_7win_patch4
-   .globl  tsetup_7win_patch5, tsetup_7win_patch6
-

[PATCH v2 24/28] sparc32: Drop unused trampoline code

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the sun4m and sun4d code from trampoline_32

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/kernel.h|   3 +-
 arch/sparc/kernel/trampoline_32.S | 127 +-
 2 files changed, 3 insertions(+), 127 deletions(-)

diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index c2aaddedf097..2c5760ff 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -112,8 +112,7 @@ extern unsigned int real_irq_entry[];
 extern unsigned int smp4d_ticker[];
 
 /* trampoline_32.S */
-extern unsigned long sun4m_cpu_startup;
-extern unsigned long sun4d_cpu_startup;
+void leon_smp_cpu_startup(int boot_cpu);
 
 /* signal_32.c */
 asmlinkage void do_sigreturn(struct pt_regs *regs);
diff --git a/arch/sparc/kernel/trampoline_32.S 
b/arch/sparc/kernel/trampoline_32.S
index 82fafeeb3a62..685b20923f6b 100644
--- a/arch/sparc/kernel/trampoline_32.S
+++ b/arch/sparc/kernel/trampoline_32.S
@@ -15,136 +15,12 @@
 #include 
 #include 
 
-   .globl sun4m_cpu_startup
-   .globl sun4d_cpu_startup
-
-   .align 4
-
 /* When we start up a cpu for the first time it enters this routine.
  * This initializes the chip from whatever state the prom left it
  * in and sets PIL in %psr to 15, no irqs.
  */
-
-sun4m_cpu_startup:
-cpu1_startup:
-   sethi   %hi(trapbase_cpu1), %g3
-   b   1f
-or %g3, %lo(trapbase_cpu1), %g3
-
-cpu2_startup:
-   sethi   %hi(trapbase_cpu2), %g3
-   b   1f
-or %g3, %lo(trapbase_cpu2), %g3
-
-cpu3_startup:
-   sethi   %hi(trapbase_cpu3), %g3
-   b   1f
-or %g3, %lo(trapbase_cpu3), %g3
-
-1:
-   /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
-   set (PSR_PIL | PSR_S | PSR_PS), %g1
-   wr  %g1, 0x0, %psr  ! traps off though
-   WRITE_PAUSE
-
-   /* Our %wim is one behind CWP */
-   mov 2, %g1
-   wr  %g1, 0x0, %wim
-   WRITE_PAUSE
-
-   /* This identifies "this cpu". */
-   wr  %g3, 0x0, %tbr
-   WRITE_PAUSE
-
-   /* Give ourselves a stack and curptr. */
-   set current_set, %g5
-   srl %g3, 10, %g4
-   and %g4, 0xc, %g4
-   ld  [%g5 + %g4], %g6
-
-   sethi   %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
-   or  %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
-   add %g6, %sp, %sp
-
-   /* Turn on traps (PSR_ET). */
-   rd  %psr, %g1
-   wr  %g1, PSR_ET, %psr   ! traps on
-   WRITE_PAUSE
-
-   /* Init our caches, etc. */
-   set poke_srmmu, %g5
-   ld  [%g5], %g5
-   call%g5
-nop
-
-   /* Start this processor. */
-   callsmp_callin
-nop
-
-   b,a smp_panic
-
.text
.align  4
-
-smp_panic:
-   callcpu_panic
-nop
-
-/* CPUID in bootbus can be found at PA 0xff014 */
-#define SUN4D_BOOTBUS_CPUID0xf014
-
-   .align  4
-
-sun4d_cpu_startup:
-   /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
-   set (PSR_PIL | PSR_S | PSR_PS), %g1
-   wr  %g1, 0x0, %psr  ! traps off though
-   WRITE_PAUSE
-
-   /* Our %wim is one behind CWP */
-   mov 2, %g1
-   wr  %g1, 0x0, %wim
-   WRITE_PAUSE
-
-   /* Set tbr - we use just one trap table. */
-   set trapbase, %g1
-   wr  %g1, 0x0, %tbr
-   WRITE_PAUSE
-
-   /* Get our CPU id out of bootbus */
-   set SUN4D_BOOTBUS_CPUID, %g3
-   lduba   [%g3] ASI_M_CTL, %g3
-   and %g3, 0xf8, %g3
-   srl %g3, 3, %g1
-   sta %g1, [%g0] ASI_M_VIKING_TMP1
-
-   /* Give ourselves a stack and curptr. */
-   set current_set, %g5
-   srl %g3, 1, %g4
-   ld  [%g5 + %g4], %g6
-
-   sethi   %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
-   or  %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
-   add %g6, %sp, %sp
-
-   /* Turn on traps (PSR_ET). */
-   rd  %psr, %g1
-   wr  %g1, PSR_ET, %psr   ! traps on
-   WRITE_PAUSE
-
-   /* Init our caches, etc. */
-   set poke_srmmu, %g5
-   ld  [%g5], %g5
-   call%g5
-nop
-
-   /* Start this processor. */
-   callsmp_callin
-nop
-
-   b,a smp_panic
-
-   .align  4
 .global leon_smp_cpu_startup, smp_penguin_ctable
 
 leon_smp_cpu_startup:
@@ -198,4 +74,5 @@ leon_smp_cpu_startup:
callsmp_callin
 nop
 
-   b,a smp_panic
+   b,a cpu_panic
+nop

-- 
2.34.1



[PATCH v2 16/28] sparc32: Drop use of sparc_config

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

sparc_config were used to handle the differences between the machines.
With only LEON supported sparc_config is no longer required.

Refactor the time code a litte as some parts are obsolete and other
parts are only used when SMP is not enabled.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: Sam Ravnborg 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/timer_32.h |  1 +
 arch/sparc/kernel/irq.h   | 37 +++---
 arch/sparc/kernel/irq_32.c|  3 --
 arch/sparc/kernel/leon_kernel.c   | 27 +++--
 arch/sparc/kernel/of_device_32.c  |  4 +--
 arch/sparc/kernel/time_32.c   | 64 +--
 6 files changed, 33 insertions(+), 103 deletions(-)

diff --git a/arch/sparc/include/asm/timer_32.h 
b/arch/sparc/include/asm/timer_32.h
index eecd2696922d..1cd89a99966f 100644
--- a/arch/sparc/include/asm/timer_32.h
+++ b/arch/sparc/include/asm/timer_32.h
@@ -17,6 +17,7 @@
 #include   /* For SUN4M_NCPUS */
 
 #define SBUS_CLOCK_RATE   200 /* 2MHz */
+#define LEON_CLOCK_RATE   100
 #define TIMER_VALUE_SHIFT 9
 #define TIMER_VALUE_MASK  0x3f
 #define TIMER_LIMIT_BIT   (1 << 31)  /* Bit 31 in Counter-Timer register */
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
index 0d9b740725b4..8a0b314c8299 100644
--- a/arch/sparc/kernel/irq.h
+++ b/arch/sparc/kernel/irq.h
@@ -44,38 +44,6 @@ struct sun4m_irq_global {
 extern struct sun4m_irq_percpu __iomem *sun4m_irq_percpu[SUN4M_NCPUS];
 extern struct sun4m_irq_global __iomem *sun4m_irq_global;
 
-/* The following definitions describe the individual platform features: */
-#define FEAT_L10_CLOCKSOURCE (1 << 0) /* L10 timer is used as a clocksource */
-#define FEAT_L10_CLOCKEVENT  (1 << 1) /* L10 timer is used as a clockevent */
-#define FEAT_L14_ONESHOT (1 << 2) /* L14 timer clockevent can oneshot */
-
-/*
- * Platform specific configuration
- * The individual platforms assign their platform
- * specifics in their init functions.
- */
-struct sparc_config {
-   void (*init_timers)(void);
-   unsigned int (*build_device_irq)(struct platform_device *op,
-unsigned int real_irq);
-
-   /* generic clockevent features - see FEAT_* above */
-   int features;
-
-   /* clock rate used for clock event timer */
-   int clock_rate;
-
-   /* one period for clock source timer */
-   unsigned int cs_period;
-
-   /* function to obtain offsett for cs period */
-   unsigned int (*get_cycles_offset)(void);
-
-   void (*clear_clock_irq)(void);
-   void (*load_profile_irq)(int cpu, unsigned int limit);
-};
-extern struct sparc_config sparc_config;
-
 unsigned int irq_alloc(unsigned int real_irq, unsigned int pil);
 void irq_link(unsigned int irq);
 void irq_unlink(unsigned int irq);
@@ -89,6 +57,11 @@ void sun4m_nmi(struct pt_regs *regs);
 /* sun4d_irq.c */
 void sun4d_handler_irq(unsigned int pil, struct pt_regs *regs);
 
+/* leon_kernel.c */
+void leon_clear_clock_irq(void);
+void leon_load_profile_irq(int cpu, unsigned int limit);
+u32 leon_cycles_offset(void);
+
 #ifdef CONFIG_SMP
 
 /* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index a6af08fce796..f76f57073323 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -24,9 +24,6 @@
 #include "kernel.h"
 #include "irq.h"
 
-/* platform specific irq setup */
-struct sparc_config sparc_config;
-
 unsigned long arch_local_irq_save(void)
 {
unsigned long retval;
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index ea04bad6a118..fa9cdaffdc6b 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -237,12 +237,6 @@ unsigned int leon_build_device_irq(unsigned int real_irq,
return irq;
 }
 
-static unsigned int _leon_build_device_irq(struct platform_device *op,
-  unsigned int real_irq)
-{
-   return leon_build_device_irq(real_irq, handle_simple_irq, "edge", 0);
-}
-
 void leon_update_virq_handling(unsigned int virq,
  irq_flow_handler_t flow_handler,
  const char *name, int do_ack)
@@ -258,7 +252,7 @@ void leon_update_virq_handling(unsigned int virq,
irq_set_chip_data(virq, (void *)mask);
 }
 
-static u32 leon_cycles_offset(void)
+u32 leon_cycles_offset(void)
 {
u32 rld, val, ctrl, off;
 
@@ -312,14 +306,6 @@ void __init leon_init_timers(void)
u32 config;
u32 ctrl;
 
-   sparc_config.get_cycles_offset = leon_cycles_offset;
-   sparc_config.cs_period = 100 / HZ;
-   sparc_config.features |= FEAT_L10_CLOCKSOURCE;
-
-#ifndef CONFIG_SMP
-   sparc_config.features |= FEAT_L10_CLOCKEVENT;
-#endif
-
leondebug_irq_disable = 0;
   

[PATCH v2 20/28] sparc32: Drop additional sun4d bits

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop sun4d specific support. Not used by LEON.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/io-unit.h |  59 
 arch/sparc/include/asm/obio.h| 226 ---
 arch/sparc/include/asm/sbi.h | 116 
 arch/sparc/kernel/entry.S|   1 -
 arch/sparc/kernel/ioport.c   |   1 -
 arch/sparc/mm/Makefile   |   2 +-
 arch/sparc/mm/io-unit.c  | 283 ---
 arch/sparc/mm/srmmu.c|   1 -
 8 files changed, 1 insertion(+), 688 deletions(-)

diff --git a/arch/sparc/include/asm/io-unit.h b/arch/sparc/include/asm/io-unit.h
deleted file mode 100644
index 8c38f5b9f927..
--- a/arch/sparc/include/asm/io-unit.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* io-unit.h: Definitions for the sun4d IO-UNIT.
- *
- * Copyright (C) 1997,1998 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
- */
-#ifndef _SPARC_IO_UNIT_H
-#define _SPARC_IO_UNIT_H
-
-#include 
-#include 
-#include 
-
-/* The io-unit handles all virtual to physical address translations
- * that occur between the SBUS and physical memory.  Access by
- * the cpu to IO registers and similar go over the xdbus so are
- * translated by the on chip SRMMU.  The io-unit and the srmmu do
- * not need to have the same translations at all, in fact most
- * of the time the translations they handle are a disjunct set.
- * Basically the io-unit handles all dvma sbus activity.
- */
- 
-/* AIEEE, unlike the nice sun4m, these monsters have 
-   fixed DMA range 64M */
- 
-#define IOUNIT_DMA_BASE0xfc00 /* TOP - 64M */
-#define IOUNIT_DMA_SIZE0x0400 /* 64M */
-/* We use last 1M for sparc_dvma_malloc */
-#define IOUNIT_DVMA_SIZE0x0010 /* 1M */
-
-/* The format of an iopte in the external page tables */
-#define IOUPTE_PAGE  0xff00 /* Physical page number (PA[35:12])
*/
-#define IOUPTE_CACHE 0x0080 /* Cached (in Viking/MXCC) 
*/
-/* XXX Jakub, find out how to program SBUS streaming cache on XDBUS/sun4d.
- * XXX Actually, all you should need to do is find out where the registers
- * XXX are and copy over the sparc64 implementation I wrote.  There may be
- * XXX some horrible hwbugs though, so be careful.  -DaveM
- */
-#define IOUPTE_STREAM0x0040 /* Translation can use streaming cache 
*/
-#define IOUPTE_INTRA0x0008 /* SBUS direct slot->slot transfer  
*/
-#define IOUPTE_WRITE 0x0004 /* Writeable   
*/
-#define IOUPTE_VALID 0x0002 /* IOPTE is valid  
*/
-#define IOUPTE_PARITY0x0001 /* Parity is checked during DVMA   
*/
-
-struct iounit_struct {
-   unsigned long   bmap[(IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 3)) / 
sizeof(unsigned long)];
-   spinlock_t  lock;
-   iopte_t __iomem *page_table;
-   unsigned long   rotor[3];
-   unsigned long   limit[4];
-};
-
-#define IOUNIT_BMAP1_START 0x
-#define IOUNIT_BMAP1_END   (IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 1))
-#define IOUNIT_BMAP2_START IOUNIT_BMAP1_END
-#define IOUNIT_BMAP2_END   IOUNIT_BMAP2_START + (IOUNIT_DMA_SIZE >> 
(PAGE_SHIFT + 2))
-#define IOUNIT_BMAPM_START IOUNIT_BMAP2_END
-#define IOUNIT_BMAPM_END   ((IOUNIT_DMA_SIZE - IOUNIT_DVMA_SIZE) >> 
PAGE_SHIFT)
-
-#endif /* !(_SPARC_IO_UNIT_H) */
diff --git a/arch/sparc/include/asm/obio.h b/arch/sparc/include/asm/obio.h
deleted file mode 100644
index 1b151f738b00..
--- a/arch/sparc/include/asm/obio.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * obio.h:  Some useful locations in 0xF PA obio space on sun4d.
- *
- * Copyright (C) 1997 Jakub Jelinek 
- */
-
-#ifndef _SPARC_OBIO_H
-#define _SPARC_OBIO_H
-
-#include 
-
-/* This weird monster likes to use the very upper parts of
-   36bit PA for these things :) */
-   
-/* CSR space (for each XDBUS)
- *  
- *  |   0xFE  |   DEVID|| XDBUS ID |   |
- *  
- *  35  28 2720 1910 98 7 0
- */
-   
-#define CSR_BASE_ADDR  0xe000
-#define CSR_CPU_SHIFT  (32 - 4 - 5)
-#define CSR_XDBUS_SHIFT8
-
-#define CSR_BASE(cpu) (((CSR_BASE_ADDR >> CSR_CPU_SHIFT) + cpu) << 
CSR_CPU_SHIFT)
-
-/* ECSR space (not for each XDBUS)
- *  
- *  |   0xF  | DEVID[7:1] |   |
- *  --

[PATCH v2 08/28] sparc32: Drop patching of interrupt vector

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the sun4m specific handling and the patching that
takes place in sun4d and LEON.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/entry.S   | 98 -
 arch/sparc/kernel/kernel.h  |  1 -
 arch/sparc/kernel/leon_kernel.c | 16 ---
 arch/sparc/kernel/sun4d_irq.c   | 25 ---
 4 files changed, 140 deletions(-)

diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 7cf148a996b9..9bd3813b872d 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -79,15 +79,6 @@ bad_trap_handler:
 real_irq_entry:
SAVE_ALL
 
-#ifdef CONFIG_SMP
-   .globl  patchme_maybe_smp_msg
-
-   cmp %l7, 11
-patchme_maybe_smp_msg:
-   bgu maybe_smp4m_msg
-nop
-#endif
-
 real_irq_continue:
or  %l0, PSR_PIL, %g2
wr  %g2, 0x0, %psr
@@ -105,95 +96,6 @@ patch_handler_irq:
RESTORE_ALL
 
 #ifdef CONFIG_SMP
-   /* SMP per-cpu ticker interrupts are handled specially. */
-smp4m_ticker:
-   bne real_irq_continue+4
-or %l0, PSR_PIL, %g2
-   wr  %g2, 0x0, %psr
-   WRITE_PAUSE
-   wr  %g2, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4m_percpu_timer_interrupt
-add%sp, STACKFRAME_SZ, %o0
-   wr  %l0, PSR_ET, %psr
-   WRITE_PAUSE
-   RESTORE_ALL
-
-#define GET_PROCESSOR4M_ID(reg)\
-   rd  %tbr, %reg; \
-   srl %reg, 12, %reg; \
-   and %reg, 3, %reg;
-
-   /* Here is where we check for possible SMP IPI passed to us
-* on some level other than 15 which is the NMI and only used
-* for cross calls.  That has a separate entry point below.
-*
-* IPIs are sent on Level 12, 13 and 14. See IRQ_IPI_*.
-*/
-maybe_smp4m_msg:
-   GET_PROCESSOR4M_ID(o3)
-   sethi   %hi(sun4m_irq_percpu), %l5
-   sll %o3, 2, %o3
-   or  %l5, %lo(sun4m_irq_percpu), %o5
-   sethi   %hi(0x7000), %o2! Check all soft-IRQs
-   ld  [%o5 + %o3], %o1
-   ld  [%o1 + 0x00], %o3   ! sun4m_irq_percpu[cpu]->pending
-   andcc   %o3, %o2, %g0
-   be,asmp4m_ticker
-cmp%l7, 14
-   /* Soft-IRQ IPI */
-   st  %o2, [%o1 + 0x04]   ! 
sun4m_irq_percpu[cpu]->clear=0x7000
-   WRITE_PAUSE
-   ld  [%o1 + 0x00], %g0   ! sun4m_irq_percpu[cpu]->pending
-   WRITE_PAUSE
-   or  %l0, PSR_PIL, %l4
-   wr  %l4, 0x0, %psr
-   WRITE_PAUSE
-   wr  %l4, PSR_ET, %psr
-   WRITE_PAUSE
-   srl %o3, 28, %o2! shift for simpler checks below
-maybe_smp4m_msg_check_single:
-   andcc   %o2, 0x1, %g0
-   beq,a   maybe_smp4m_msg_check_mask
-andcc  %o2, 0x2, %g0
-   callsmp_call_function_single_interrupt
-nop
-   andcc   %o2, 0x2, %g0
-maybe_smp4m_msg_check_mask:
-   beq,a   maybe_smp4m_msg_check_resched
-andcc  %o2, 0x4, %g0
-   callsmp_call_function_interrupt
-nop
-   andcc   %o2, 0x4, %g0
-maybe_smp4m_msg_check_resched:
-   /* rescheduling is done in RESTORE_ALL regardless, but incr stats */
-   beq,a   maybe_smp4m_msg_out
-nop
-   callsmp_resched_interrupt
-nop
-maybe_smp4m_msg_out:
-   RESTORE_ALL
-
-
-   .globl  smp4d_ticker
-   /* SMP per-cpu ticker interrupts are handled specially. */
-smp4d_ticker:
-   SAVE_ALL
-   or  %l0, PSR_PIL, %g2
-   sethi   %hi(CC_ICLR), %o0
-   sethi   %hi(1 << 14), %o1
-   or  %o0, %lo(CC_ICLR), %o0
-   stha%o1, [%o0] ASI_M_MXCC   /* Clear PIL 14 in MXCC's ICLR */
-   wr  %g2, 0x0, %psr
-   WRITE_PAUSE
-   wr  %g2, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4d_percpu_timer_interrupt
-add%sp, STACKFRAME_SZ, %o0
-   wr  %l0, PSR_ET, %psr
-   WRITE_PAUSE
-   RESTORE_ALL
-
.globl  smpleon_ipi
.extern leon_ipi_interrupt
/* SMP per-cpu IPI interrupts are handled specially. */
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 3ba842c6b6da..6165e1b26df7 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -145,7 +145,6 @@ extern char cputypval[];
 extern unsigned long lvl14_save[4];
 extern unsigned int real_irq_entry[];
 extern unsigned int smp4d_ticker[];
-extern unsigned int patchme_maybe_smp_msg[];
 
 /* trampoline_32.S */
 extern unsigned long sun4m_cpu_startup;
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index 4c61da491fee..ea04bad6a118 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -421,22 +421,6 @@ void __init leon_init_timers(void)
if (eirq != 0)
leon_eirq_setup(eirq);
 
-#ifdef CONFIG_SMP
-   {
- 

[PATCH v2 23/28] sparc32: Drop sun4m irq support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop all code used to support sun4m irqs.
Update entry.S to call the leon_nmi function.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/Makefile  |   1 -
 arch/sparc/kernel/entry.S   |  29 ++---
 arch/sparc/kernel/irq.h |  46 +---
 arch/sparc/kernel/irq_32.c  |   6 +-
 arch/sparc/kernel/kernel.h  |   4 -
 arch/sparc/kernel/leon_kernel.c |  10 +-
 arch/sparc/kernel/sun4m_irq.c   | 238 
 7 files changed, 23 insertions(+), 311 deletions(-)

diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 50d696c8a9d2..fd3d1ebfb1ea 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -28,7 +28,6 @@ obj-y   += traps_$(BITS).o
 
 # IRQ
 obj-y   += irq_$(BITS).o
-obj-$(CONFIG_SPARC32)   += sun4m_irq.o
 
 obj-y   += process_$(BITS).o
 obj-y   += process.o
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index bbbf30c60f1c..3de018a44915 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -427,36 +427,21 @@ setcc_trap_handler:
jmp %l2 ! advance over trap instruction
rett%l2 + 0x4   ! like this...
 
-sun4m_nmi_error:
+nmi_error:
/* NMI async memory error handling. */
-   sethi   %hi(0x8000), %l4
-   sethi   %hi(sun4m_irq_global), %o5
-   ld  [%o5 + %lo(sun4m_irq_global)], %l5
-   st  %l4, [%l5 + 0x0c]   ! sun4m_irq_global->mask_set=0x8000
-   WRITE_PAUSE
-   ld  [%l5 + 0x00], %g0   ! sun4m_irq_global->pending
-   WRITE_PAUSE
+#ifndef CONFIG_SMP
+   .align  4
+   .globl  linux_trap_ipi15_leon
+linux_trap_ipi15_leon:
+   SAVE_ALL
or  %l0, PSR_PIL, %l4
wr  %l4, 0x0, %psr
WRITE_PAUSE
wr  %l4, PSR_ET, %psr
WRITE_PAUSE
-   callsun4m_nmi
+   callleon_nmi
 nop
-   st  %l4, [%l5 + 0x08]   ! 
sun4m_irq_global->mask_clear=0x8000
-   WRITE_PAUSE
-   ld  [%l5 + 0x00], %g0   ! sun4m_irq_global->pending
-   WRITE_PAUSE
RESTORE_ALL
-
-#ifndef CONFIG_SMP
-   .align  4
-   .globl  linux_trap_ipi15_leon
-linux_trap_ipi15_leon:
-   SAVE_ALL
-
-   ba  sun4m_nmi_error
-nop
 #endif /* CONFIG_SMP */
 
.align  4
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
index 8a0b314c8299..f0aacc5c9ea6 100644
--- a/arch/sparc/kernel/irq.h
+++ b/arch/sparc/kernel/irq.h
@@ -10,39 +10,14 @@ struct irq_bucket {
 unsigned int pil;
 };
 
-#define SUN4M_HARD_INT(x)   (0x1 << (x))
-#define SUN4M_SOFT_INT(x)   (0x1 << (x))
-
-#define SUN4D_MAX_BOARD 10
-#define SUN4D_MAX_IRQ ((SUN4D_MAX_BOARD + 2) << 5)
+#define MAX_BOARD 10
+#define MAX_IRQ ((MAX_BOARD + 2) << 5)
 
 /* Map between the irq identifier used in hw to the
  * irq_bucket. The map is sufficient large to hold
  * the sun4d hw identifiers.
  */
-extern struct irq_bucket *irq_map[SUN4D_MAX_IRQ];
-
-
-/* sun4m specific type definitions */
-
-/* This maps direct to CPU specific interrupt registers */
-struct sun4m_irq_percpu {
-   u32 pending;
-   u32 clear;
-   u32 set;
-};
-
-/* This maps direct to global interrupt registers */
-struct sun4m_irq_global {
-   u32 pending;
-   u32 mask;
-   u32 mask_clear;
-   u32 mask_set;
-   u32 interrupt_target;
-};
-
-extern struct sun4m_irq_percpu __iomem *sun4m_irq_percpu[SUN4M_NCPUS];
-extern struct sun4m_irq_global __iomem *sun4m_irq_global;
+extern struct irq_bucket *irq_map[MAX_IRQ];
 
 unsigned int irq_alloc(unsigned int real_irq, unsigned int pil);
 void irq_link(unsigned int irq);
@@ -51,22 +26,9 @@ void handler_irq(unsigned int pil, struct pt_regs *regs);
 
 unsigned long leon_get_irqmask(unsigned int irq);
 
-/* sun4m_irq.c */
-void sun4m_nmi(struct pt_regs *regs);
-
-/* sun4d_irq.c */
-void sun4d_handler_irq(unsigned int pil, struct pt_regs *regs);
-
 /* leon_kernel.c */
 void leon_clear_clock_irq(void);
 void leon_load_profile_irq(int cpu, unsigned int limit);
 u32 leon_cycles_offset(void);
 
-#ifdef CONFIG_SMP
-
-/* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
-#define SUN4D_IPI_IRQ 13
-
-void sun4d_ipi_interrupt(void);
-
-#endif
+void leon_nmi(struct pt_regs *regs);
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index f76f57073323..5bd64828e8a0 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -111,7 +111,7 @@ static struct irq_bucket irq_table[NR_IRQS];
 static DEFINE_SPINLOCK(irq_table_lock);
 
 /* Map between the irq identifier used in hw to the irq_bucket. */
-struct irq_bucket *irq_map[SUN4D_MAX_IRQ];
+struct irq_bucket *irq_map[MAX_

[PATCH v2 12/28] sparc32: Drop mbus support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Only used by older SPARC HW, not used by LEON.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/elf_32.h |  2 -
 arch/sparc/include/asm/mbus.h   | 97 -
 arch/sparc/kernel/cpu.c |  1 -
 arch/sparc/kernel/setup_32.c|  1 -
 arch/sparc/mm/iommu.c   | 18 ++--
 arch/sparc/mm/srmmu.c   | 48 
 6 files changed, 3 insertions(+), 164 deletions(-)

diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
index 37a6016c9ccd..b2cca9be55c2 100644
--- a/arch/sparc/include/asm/elf_32.h
+++ b/arch/sparc/include/asm/elf_32.h
@@ -91,8 +91,6 @@ typedef struct {
unsigned intpr_q[64];
 } elf_fpregset_t;
 
-#include 
-
 /*
  * This is used to ensure we don't load something for the wrong architecture.
  */
diff --git a/arch/sparc/include/asm/mbus.h b/arch/sparc/include/asm/mbus.h
deleted file mode 100644
index 8b6dbe701b9b..
--- a/arch/sparc/include/asm/mbus.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * mbus.h:  Various defines for MBUS modules.
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#ifndef _SPARC_MBUS_H
-#define _SPARC_MBUS_H
-
-#include /* HyperSparc stuff */
-#include   /* Ugh, bug city... */
-
-enum mbus_module {
-   HyperSparc= 0,
-   Swift_ok  = 4,
-   Swift_bad_c   = 5,
-   Swift_lots_o_bugs = 6,
-   Tsunami   = 7,
-   Viking_12 = 8,
-   Viking_2x = 9,
-   Viking_30 = 10,
-   Viking_35 = 11,
-   Viking_new= 12,
-   TurboSparc= 13,
-   SRMMU_INVAL_MOD   = 14,
-};
-
-extern enum mbus_module srmmu_modtype;
-extern unsigned int viking_rev, swift_rev, cypress_rev;
-
-/* HW Mbus module bugs we have to deal with */
-#define HWBUG_COPYBACK_BROKEN0x0001
-#define HWBUG_ASIFLUSH_BROKEN0x0002
-#define HWBUG_VACFLUSH_BITROT0x0004
-#define HWBUG_KERN_ACCBROKEN 0x0008
-#define HWBUG_KERN_CBITBROKEN0x0010
-#define HWBUG_MODIFIED_BITROT0x0020
-#define HWBUG_PC_BADFAULT_ADDR   0x0040
-#define HWBUG_SUPERSCALAR_BAD0x0080
-#define HWBUG_PACINIT_BITROT 0x0100
-
-/* First the module type values. To find out which you have, just load
- * the mmu control register from ASI_M_MMUREG alternate address space and
- * shift the value right 28 bits.
- */
-/* IMPL field means the company which produced the chip. */
-#define MBUS_VIKING0x4   /* bleech, Texas Instruments Module */
-#define MBUS_LSI   0x3   /* LSI Logics */
-#define MBUS_ROSS  0x1   /* Ross is nice */
-#define MBUS_FMI   0x0   /* Fujitsu Microelectronics/Swift */
-
-/* Ross Module versions */
-#define ROSS_604_REV_CDE0x0   /* revisions c, d, and e */
-#define ROSS_604_REV_F  0x1   /* revision f */
-#define ROSS_6050xf   /* revision a, a.1, and a.2 */
-#define ROSS_605_REV_B  0xe   /* revision b */
-
-/* TI Viking Module versions */
-#define VIKING_REV_12   0x1   /* Version 1.2 or SPARCclassic's CPU */
-#define VIKING_REV_20x2   /* Version 2.1, 2.2, 2.3, and 2.4 */
-#define VIKING_REV_30   0x3   /* Version 3.0 */
-#define VIKING_REV_35   0x4   /* Version 3.5 */
-
-/* LSI Logics. */
-#define LSI_L64815 0x0
-
-/* Fujitsu */
-#define FMI_AURORA 0x4   /* MB8690x, a Swift module... */
-#define FMI_TURBO  0x5   /* MB86907, a TurboSparc module... */
-
-/* For multiprocessor support we need to be able to obtain the CPU id and
- * the MBUS Module id.
- */
-
-/* The CPU ID is encoded in the trap base register, 20 bits to the left of
- * bit zero, with 2 bits being significant.
- */
-#define TBR_ID_SHIFT20
-
-static inline int get_cpuid(void)
-{
-   register int retval;
-   __asm__ __volatile__("rd %%tbr, %0\n\t"
-"srl %0, %1, %0\n\t" :
-"=r" (retval) :
-"i" (TBR_ID_SHIFT));
-   return (retval & 3);
-}
-
-static inline int get_modid(void)
-{
-   return (get_cpuid() | 0x8);
-}
-
-   
-#endif /* !(_SPARC_MBUS_H) */
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
index 79cd6ccfeac0..cca7de051593 100644
--- a/arch/sparc/kernel/cpu.c
+++ b/arch/sparc/kernel/cpu.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "kernel.h"
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 704375c061e7..3c6c16fde8c3 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -41,7 +41,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #inc

[PATCH v2 22/28] sparc32: Drop unused sbus iommu support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

LEON do not have sbus iommu support - drop it.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/iommu.h|   2 -
 arch/sparc/include/asm/iommu_32.h | 122 ---
 arch/sparc/kernel/ioport.c|   1 -
 arch/sparc/mm/Makefile|   2 +-
 arch/sparc/mm/iommu.c | 420 --
 arch/sparc/mm/mm_32.h |   3 -
 arch/sparc/mm/srmmu.c |   3 -
 7 files changed, 1 insertion(+), 552 deletions(-)

diff --git a/arch/sparc/include/asm/iommu.h b/arch/sparc/include/asm/iommu.h
index 37935cb34865..ea07526ff476 100644
--- a/arch/sparc/include/asm/iommu.h
+++ b/arch/sparc/include/asm/iommu.h
@@ -3,7 +3,5 @@
 #define ___ASM_SPARC_IOMMU_H
 #if defined(__sparc__) && defined(__arch64__)
 #include 
-#else
-#include 
 #endif
 #endif
diff --git a/arch/sparc/include/asm/iommu_32.h 
b/arch/sparc/include/asm/iommu_32.h
deleted file mode 100644
index af51cd5ea3c1..
--- a/arch/sparc/include/asm/iommu_32.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* iommu.h: Definitions for the sun4m IOMMU.
- *
- * Copyright (C) 1996 David S. Miller (da...@caip.rutgers.edu)
- */
-#ifndef _SPARC_IOMMU_H
-#define _SPARC_IOMMU_H
-
-#include 
-#include 
-
-/* The iommu handles all virtual to physical address translations
- * that occur between the SBUS and physical memory.  Access by
- * the cpu to IO registers and similar go over the mbus so are
- * translated by the on chip SRMMU.  The iommu and the srmmu do
- * not need to have the same translations at all, in fact most
- * of the time the translations they handle are a disjunct set.
- * Basically the iommu handles all dvma sbus activity.
- */
-
-/* The IOMMU registers occupy three pages in IO space. */
-struct iommu_regs {
-   /* First page */
-   volatile unsigned long control;/* IOMMU control */
-   volatile unsigned long base;   /* Physical base of iopte page table 
*/
-   volatile unsigned long _unused1[3];
-   volatile unsigned long tlbflush;   /* write only */
-   volatile unsigned long pageflush;  /* write only */
-   volatile unsigned long _unused2[1017];
-   /* Second page */
-   volatile unsigned long afsr;   /* Async-fault status register */
-   volatile unsigned long afar;   /* Async-fault physical address */
-   volatile unsigned long _unused3[2];
-   volatile unsigned long sbuscfg0;   /* SBUS configuration registers, 
per-slot */
-   volatile unsigned long sbuscfg1;
-   volatile unsigned long sbuscfg2;
-   volatile unsigned long sbuscfg3;
-   volatile unsigned long mfsr;   /* Memory-fault status register */
-   volatile unsigned long mfar;   /* Memory-fault physical address */
-   volatile unsigned long _unused4[1014];
-   /* Third page */
-   volatile unsigned long mid;/* IOMMU module-id */
-};
-
-#define IOMMU_CTRL_IMPL 0xf000 /* Implementation */
-#define IOMMU_CTRL_VERS 0x0f00 /* Version */
-#define IOMMU_CTRL_RNGE 0x001c /* Mapping RANGE */
-#define IOMMU_RNGE_16MB 0x /* 0xff00 -> 0x */
-#define IOMMU_RNGE_32MB 0x0004 /* 0xfe00 -> 0x */
-#define IOMMU_RNGE_64MB 0x0008 /* 0xfc00 -> 0x */
-#define IOMMU_RNGE_128MB0x000c /* 0xf800 -> 0x */
-#define IOMMU_RNGE_256MB0x0010 /* 0xf000 -> 0x */
-#define IOMMU_RNGE_512MB0x0014 /* 0xe000 -> 0x */
-#define IOMMU_RNGE_1GB  0x0018 /* 0xc000 -> 0x */
-#define IOMMU_RNGE_2GB  0x001c /* 0x8000 -> 0x */
-#define IOMMU_CTRL_ENAB 0x0001 /* IOMMU Enable */
-
-#define IOMMU_AFSR_ERR  0x8000 /* LE, TO, or BE asserted */
-#define IOMMU_AFSR_LE   0x4000 /* SBUS reports error after transaction 
*/
-#define IOMMU_AFSR_TO   0x2000 /* Write access took more than 12.8 us. 
*/
-#define IOMMU_AFSR_BE   0x1000 /* Write access received error 
acknowledge */
-#define IOMMU_AFSR_SIZE 0x0e00 /* Size of transaction causing error */
-#define IOMMU_AFSR_S0x0100 /* Sparc was in supervisor mode */
-#define IOMMU_AFSR_RESV 0x00f0 /* Reserver, forced to 0x8 by hardware 
*/
-#define IOMMU_AFSR_ME   0x0008 /* Multiple errors occurred */
-#define IOMMU_AFSR_RD   0x0004 /* A read operation was in progress */
-#define IOMMU_AFSR_FAV  0x0002 /* IOMMU afar has valid contents */
-
-#define IOMMU_SBCFG_SAB30   0x0001 /* Phys-address bit 30 when bypass 
enabled */
-#define IOMMU_SBCFG_BA160x0004 /* Slave supports 16 byte bursts */
-#define IOMMU_SBCFG_BA8 0x0002 /* Slave supports 8 byte bursts */
-#define IOMMU_SBCFG_BYPASS  0x0001 /* Bypass IOMMU, treat all addresses
-  

[PATCH v2 25/28] sparc32: Drop config SPARC_LEON

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The only supported sparc32 CPU is LEON, so there is no need for a
config option to select it.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Acked-by: Greg Kroah-Hartman  #For the USB stuff
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig   | 27 +--
 arch/sparc/configs/sparc32_defconfig |  1 -
 drivers/usb/host/Kconfig |  2 +-
 drivers/usb/host/ehci-hcd.c  |  4 ++--
 drivers/usb/host/uhci-hcd.c  |  2 +-
 5 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 19ee7bc0b2ea..e4e2548c1f1f 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -9,6 +9,10 @@ config 64BIT
 
  Say yes to build a 64-bit kernel - formerly known as sparc64
  Say no to build a 32-bit kernel - formerly known as sparc
+ The 32-bit kernel target the synthesizable LEON SPARC processor.
+ LEON is a part of the GRLIB collection of IP cores that are
+ distributed under GPL. GRLIB can be downloaded from www.gaisler.com.
+ You can download a sparc-linux cross-compilation toolchain at 
www.gaisler.com.
 
 config SPARC
bool
@@ -62,6 +66,10 @@ config SPARC32
select HAVE_UID16
select LOCK_MM_AND_FIND_VMA
select OLD_SIGACTION
+   select USB_EHCI_BIG_ENDIAN_MMIO
+   select USB_EHCI_BIG_ENDIAN_DESC
+   select USB_UHCI_BIG_ENDIAN_MMIO
+   select USB_UHCI_BIG_ENDIAN_DESC
select ZONE_DMA
 
 config SPARC64
@@ -344,22 +352,6 @@ config SERIAL_CONSOLE
 
  If unsure, say N.
 
-config SPARC_LEON
-   bool "Sparc Leon processor family"
-   depends on SPARC32
-   select USB_EHCI_BIG_ENDIAN_MMIO
-   select USB_EHCI_BIG_ENDIAN_DESC
-   select USB_UHCI_BIG_ENDIAN_MMIO
-   select USB_UHCI_BIG_ENDIAN_DESC
-   help
- If you say Y here if you are running on a SPARC-LEON processor.
- The LEON processor is a synthesizable VHDL model of the
- SPARC-v8 standard. LEON is  part of the GRLIB collection of
- IP cores that are distributed under GPL. GRLIB can be downloaded
- from www.gaisler.com. You can download a sparc-linux cross-compilation
- toolchain at www.gaisler.com.
-
-if SPARC_LEON
 menu "U-Boot options"
 
 config UBOOT_LOAD_ADDR
@@ -390,7 +382,6 @@ config UBOOT_ENTRY_ADDR
 Kernel.
 
 endmenu
-endif
 
 endmenu
 
@@ -412,7 +403,7 @@ config SUN_LDOMS
 
 config LEON_PCI
bool
-   depends on PCI && SPARC_LEON
+   depends on PCI && SPARC32
default y
 
 config SPARC_GRPCI1
diff --git a/arch/sparc/configs/sparc32_defconfig 
b/arch/sparc/configs/sparc32_defconfig
index 71273fc578bf..dfd326f20876 100644
--- a/arch/sparc/configs/sparc32_defconfig
+++ b/arch/sparc/configs/sparc32_defconfig
@@ -10,7 +10,6 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_RD_ZSTD is not set
 CONFIG_SMP=y
 CONFIG_HZ_100=y
-CONFIG_SPARC_LEON=y
 CONFIG_SUN_OPENPROMFS=y
 CONFIG_SUN_OPENPROMIO=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 4448d0ab06f0..c5f94c70482f 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -595,7 +595,7 @@ config USB_UHCI_HCD
 
 config USB_UHCI_SUPPORT_NON_PCI_HC
bool
-   default y if (SPARC_LEON || USB_UHCI_PLATFORM)
+   default y if (SPARC32 || USB_UHCI_PLATFORM)
 
 config USB_UHCI_PLATFORM
bool
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 802bfafb1012..5011bc8348bb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1329,7 +1329,7 @@ MODULE_LICENSE ("GPL");
 #include "ehci-xilinx-of.c"
 #endif
 
-#ifdef CONFIG_SPARC_LEON
+#ifdef CONFIG_SPARC32
 #include "ehci-grlib.c"
 #endif
 
@@ -1343,7 +1343,7 @@ static struct platform_driver * const platform_drivers[] 
= {
 #ifdef CONFIG_XPS_USB_HCD_XILINX
_hcd_xilinx_of_driver,
 #endif
-#ifdef CONFIG_SPARC_LEON
+#ifdef CONFIG_SPARC32
_grlib_driver,
 #endif
 };
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index fd2408b553cf..7cb820963988 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -846,7 +846,7 @@ static const char hcd_name[] = "uhci_hcd";
 #definePCI_DRIVER  uhci_pci_driver
 #endif
 
-#ifdef CONFIG_SPARC_LEON
+#ifdef CONFIG_SPARC32
 #include "uhci-grlib.c"
 #define PLATFORM_DRIVERuhci_grlib_driver
 #endif

-- 
2.34.1



[PATCH v2 17/28] sparc32: Drop run-time cpuid patching

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The CPU is always leon, so the run-time cpuid patching is no longer
required.

Signed-off-by: Sam Ravnborg 
Reported-by: Andreas Larsson 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/winmacro.h | 12 
 arch/sparc/kernel/entry.S | 13 -
 arch/sparc/kernel/setup_32.c  | 31 ---
 3 files changed, 56 deletions(-)

diff --git a/arch/sparc/include/asm/winmacro.h 
b/arch/sparc/include/asm/winmacro.h
index b6e911f5d93c..16144900bd6c 100644
--- a/arch/sparc/include/asm/winmacro.h
+++ b/arch/sparc/include/asm/winmacro.h
@@ -105,21 +105,9 @@
 
 #ifdef CONFIG_SMP
 #define LOAD_CURRENT(dest_reg, idreg)  \
-661:   rd  %tbr, %idreg;   \
-   srl %idreg, 10, %idreg; \
-   and %idreg, 0xc, %idreg;\
-   .section.cpuid_patch, "ax"; \
-   /* Instruction location. */ \
-   .word   661b;   \
-   /* SUN4D implementation. */ \
-   lda  [%g0] ASI_M_VIKING_TMP1, %idreg;   \
-   sll  %idreg, 2, %idreg; \
-   nop;\
-   /* LEON implementation. */  \
rd  %asr17, %idreg; \
srl %idreg, 0x1c, %idreg;   \
sll %idreg, 0x02, %idreg;   \
-   .previous;  \
sethi%hi(current_set), %dest_reg;   \
or   %dest_reg, %lo(current_set), %dest_reg;\
ld   [%idreg + %dest_reg], %dest_reg;
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 0f2417ee3f95..f158cbca3e62 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -984,21 +984,8 @@ flushw_all:
 
 #ifdef CONFIG_SMP
 ENTRY(hard_smp_processor_id)
-661:   rd  %tbr, %g1
-   srl %g1, 12, %o0
-   and %o0, 3, %o0
-   .section.cpuid_patch, "ax"
-   /* Instruction location. */
-   .word   661b
-   /* SUN4D implementation. */
-   lda [%g0] ASI_M_VIKING_TMP1, %o0
-   nop
-   nop
-   /* LEON implementation. */
rd  %asr17, %o0
srl %o0, 0x1c, %o0
-   nop
-   .previous
retl
 nop
 ENDPROC(hard_smp_processor_id)
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 0f38d72aae2d..af5f143ed882 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -178,34 +178,6 @@ extern int root_mountflags;
 
 char reboot_command[COMMAND_LINE_SIZE];
 
-struct cpuid_patch_entry {
-   unsigned intaddr;
-   unsigned intsun4d[3];
-   unsigned intleon[3];
-};
-extern struct cpuid_patch_entry __cpuid_patch, __cpuid_patch_end;
-
-static void __init per_cpu_patch(void)
-{
-   struct cpuid_patch_entry *p;
-
-   p = &__cpuid_patch;
-   while (p < &__cpuid_patch_end) {
-   unsigned long addr = p->addr;
-   unsigned int *insns;
-
-   insns = >leon[0];
-   *(unsigned int *) (addr + 0) = insns[0];
-   flushi(addr + 0);
-   *(unsigned int *) (addr + 4) = insns[1];
-   flushi(addr + 4);
-   *(unsigned int *) (addr + 8) = insns[2];
-   flushi(addr + 8);
-
-   p++;
-   }
-}
-
 static __init void leon_patch(void)
 {
/* Default instruction is leon - no patching */
@@ -271,9 +243,6 @@ void __init setup_arch(char **cmdline_p)
(*(linux_dbvec->teach_debugger))();
}
 
-   /* Run-time patch instructions to match the cpu model */
-   per_cpu_patch();
-
paging_init();
 
smp_setup_cpu_possible_map();

-- 
2.34.1



[PATCH v2 00/28] sparc32: sunset sun4m and sun4d

2024-03-09 Thread Sam Ravnborg via B4 Relay
This is the second attempt to sunset sun4m and sun4d.
See [1] for the inital attempt.

The sun4m and sun4d parts of the kernel have seen no real interest
for several years now. Last time a few people surfaced, but it was
either due to a personal project or for nostalgic reasons.
It is time to let go and drop the parts of sparc32 that in reality
are not in use.

LEON from Frontgrade Gaisler is the only real user of sparc32,
and this patchset reduces sparc32 to what is required by LEON.

The defconfig is first adapted to the one used by Gaisler.
Then the patches removes sun4m and sun4d specific
implementations such as small drivers, SMP support, IRQ suppor etc.

Removing sun4m and sun4d support allowed removal of the run time
patching of the code as well as a lot of assembler code.
The result is a much cleaner assembler code that is easier to
understand and thus maintain and extend.

Changes in v2:
  - Rebased on top of Andreas' for-next branch
  - Collected ack's
  - Added patch to remove cpuid patching (Andreas)
  - Run-time testing using qemu (Andreas, Mark Cave-Ayland)

Sam

[1]: https://lore.kernel.org/all/20201218184347.2180772-1-...@ravnborg.org/

---
Sam Ravnborg (28):
  sparc32: Update defconfig to LEON SMP
  sparc32: Drop sun4m/sun4d support from head_32.S
  sparc32: Drop floppy support
  sparc32: Drop sun4m specific led driver
  sparc32: Drop sun specific power management drivers
  sparc32: Drop auxio support
  sparc32: Drop run-time patching of ipi trap
  sparc32: Drop patching of interrupt vector
  sparc32: Drop sun4m/sun4d specific irq handling
  sparc32: Drop sun4d/sun4m smp support
  sparc32: Drop pcic support
  sparc32: Drop mbus support
  sparc32: Drop unused function __get_{phys,iospace}
  sparc32: Drop unused mmu models
  sparc32: Drop check for sparc_model
  sparc32: Drop use of sparc_config
  sparc32: Drop run-time cpuid patching
  sparc32: Drop run-time patching of ASI instructions
  sparc32: Drop support for 7 register windows
  sparc32: Drop additional sun4d bits
  sparc32: Drop unused prom ranges support
  sparc32: Drop unused sbus iommu support
  sparc32: Drop sun4m irq support
  sparc32: Drop unused trampoline code
  sparc32: Drop config SPARC_LEON
  sparc32: Drop sbus support
  sbus: char: Drop now unused uctrl driver
  fbdev/p9100: Drop now unused driver p9100

 arch/sparc/Kconfig|  54 +--
 arch/sparc/configs/sparc32_defconfig  | 170 +++
 arch/sparc/include/asm/asmmacro.h |  22 -
 arch/sparc/include/asm/auxio_32.h |  73 +--
 arch/sparc/include/asm/cpu_type.h |  18 -
 arch/sparc/include/asm/elf_32.h   |   2 -
 arch/sparc/include/asm/fb.h   |   8 +-
 arch/sparc/include/asm/floppy.h   |   2 -
 arch/sparc/include/asm/floppy_32.h| 393 
 arch/sparc/include/asm/io-unit.h  |  59 ---
 arch/sparc/include/asm/io_32.h|  83 
 arch/sparc/include/asm/iommu.h|   2 -
 arch/sparc/include/asm/iommu_32.h | 122 -
 arch/sparc/include/asm/irq_32.h   |   2 -
 arch/sparc/include/asm/mbus.h |  97 
 arch/sparc/include/asm/mxcc.h | 138 --
 arch/sparc/include/asm/obio.h | 226 -
 arch/sparc/include/asm/oplib_32.h |  11 -
 arch/sparc/include/asm/pcic.h | 130 --
 arch/sparc/include/asm/pgtable_32.h   |  24 -
 arch/sparc/include/asm/pgtsrmmu.h |  33 +-
 arch/sparc/include/asm/ross.h | 192 
 arch/sparc/include/asm/sbi.h  | 116 -
 arch/sparc/include/asm/sections.h |   3 -
 arch/sparc/include/asm/setup.h|  12 -
 arch/sparc/include/asm/swift.h| 107 -
 arch/sparc/include/asm/switch_to_32.h |   1 -
 arch/sparc/include/asm/timer_32.h |   1 +
 arch/sparc/include/asm/tsunami.h  |  65 ---
 arch/sparc/include/asm/turbosparc.h   | 126 -
 arch/sparc/include/asm/viking.h   | 255 ---
 arch/sparc/include/asm/winmacro.h |  12 -
 arch/sparc/kernel/Makefile|   8 +-
 arch/sparc/kernel/apc.c   | 196 
 arch/sparc/kernel/auxio_32.c  | 139 --
 arch/sparc/kernel/cpu.c   |   1 -
 arch/sparc/kernel/devices.c   |  10 +-
 arch/sparc/kernel/entry.S | 426 +
 arch/sparc/kernel/etrap_32.S  |  50 +-
 arch/sparc/kernel/head_32.S   | 255 +--
 arch/sparc/kernel/ioport.c|  55 +--
 arch/sparc/kernel/irq.h   |  84 +---
 arch/sparc/kernel/irq_32.c| 133 +-
 arch/sparc/kernel/kernel.h|  53 +--
 arch/sparc/kernel/led.c   | 146 --
 arch/sparc/kernel/leon_kernel.c   |  53 +--
 arch/sparc/kernel/leon_pmc.c  |  16 +-
 arch/sparc/kernel/leon_smp.c  |   3 -
 arch/sparc/kernel/of_device_32.c  |  18 +-
 arch/sparc/kernel/pcic.c  | 840 --
 arch/sparc

[PATCH v2 07/28] sparc32: Drop run-time patching of ipi trap

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

There is no longer any need for the run-time patching of the ipi trap
with the removal of sun4m and sun4d. Remove the patching and drop the
ipi implementation for the two machines.

The patch includes removal of patching from pcic as this was needed to
fix the build. pcic will be removed in a later commit.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/entry.S | 70 ++-
 arch/sparc/kernel/kernel.h|  4 ---
 arch/sparc/kernel/leon_smp.c  |  3 --
 arch/sparc/kernel/pcic.c  | 11 ---
 arch/sparc/kernel/sun4d_smp.c |  3 --
 arch/sparc/kernel/ttable_32.S |  9 +++---
 6 files changed, 7 insertions(+), 93 deletions(-)

diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index c6a5cb949381..7cf148a996b9 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -174,32 +174,6 @@ maybe_smp4m_msg_check_resched:
 maybe_smp4m_msg_out:
RESTORE_ALL
 
-   .align  4
-   .globl  linux_trap_ipi15_sun4m
-linux_trap_ipi15_sun4m:
-   SAVE_ALL
-   sethi   %hi(0x8000), %o2
-   GET_PROCESSOR4M_ID(o0)
-   sethi   %hi(sun4m_irq_percpu), %l5
-   or  %l5, %lo(sun4m_irq_percpu), %o5
-   sll %o0, 2, %o0
-   ld  [%o5 + %o0], %o5
-   ld  [%o5 + 0x00], %o3   ! sun4m_irq_percpu[cpu]->pending
-   andcc   %o3, %o2, %g0
-   be  sun4m_nmi_error ! Must be an NMI async memory error
-st %o2, [%o5 + 0x04]   ! 
sun4m_irq_percpu[cpu]->clear=0x8000
-   WRITE_PAUSE
-   ld  [%o5 + 0x00], %g0   ! sun4m_irq_percpu[cpu]->pending
-   WRITE_PAUSE
-   or  %l0, PSR_PIL, %l4
-   wr  %l4, 0x0, %psr
-   WRITE_PAUSE
-   wr  %l4, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4m_cross_call_irq
-nop
-   b   ret_trap_lockless_ipi
-clr%l6
 
.globl  smp4d_ticker
/* SMP per-cpu ticker interrupts are handled specially. */
@@ -220,44 +194,6 @@ smp4d_ticker:
WRITE_PAUSE
RESTORE_ALL
 
-   .align  4
-   .globl  linux_trap_ipi15_sun4d
-linux_trap_ipi15_sun4d:
-   SAVE_ALL
-   sethi   %hi(CC_BASE), %o4
-   sethi   %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
-   or  %o4, (CC_EREG - CC_BASE), %o0
-   ldda[%o0] ASI_M_MXCC, %o0
-   andcc   %o0, %o2, %g0
-   bne 1f
-sethi  %hi(BB_STAT2), %o2
-   lduba   [%o2] ASI_M_CTL, %o2
-   andcc   %o2, BB_STAT2_MASK, %g0
-   bne 2f
-or %o4, (CC_ICLR - CC_BASE), %o0
-   sethi   %hi(1 << 15), %o1
-   stha%o1, [%o0] ASI_M_MXCC   /* Clear PIL 15 in MXCC's ICLR */
-   or  %l0, PSR_PIL, %l4
-   wr  %l4, 0x0, %psr
-   WRITE_PAUSE
-   wr  %l4, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4d_cross_call_irq
-nop
-   b   ret_trap_lockless_ipi
-clr%l6
-
-1: /* MXCC error */
-2: /* BB error */
-   /* Disable PIL 15 */
-   set CC_IMSK, %l4
-   lduha   [%l4] ASI_M_MXCC, %l5
-   sethi   %hi(1 << 15), %l7
-   or  %l5, %l7, %l5
-   stha%l5, [%l4] ASI_M_MXCC
-   /* FIXME */
-1: b,a 1b
-
.globl  smpleon_ipi
.extern leon_ipi_interrupt
/* SMP per-cpu IPI interrupts are handled specially. */
@@ -618,11 +554,11 @@ sun4m_nmi_error:
 
 #ifndef CONFIG_SMP
.align  4
-   .globl  linux_trap_ipi15_sun4m
-linux_trap_ipi15_sun4m:
+   .globl  linux_trap_ipi15_leon
+linux_trap_ipi15_leon:
SAVE_ALL
 
-   ba  sun4m_nmi_error
+   ba  sun4m_nmi_error
 nop
 #endif /* CONFIG_SMP */
 
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 64703be6c015..3ba842c6b6da 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -134,10 +134,6 @@ void leonsmp_ipi_interrupt(void);
 void leon_cross_call_irq(void);
 
 /* head_32.S */
-extern unsigned int t_nmi[];
-extern unsigned int linux_trap_ipi15_sun4d[];
-extern unsigned int linux_trap_ipi15_sun4m[];
-
 extern struct tt_entry trapbase[];
 extern struct tt_entry trapbase_cpu1[];
 extern struct tt_entry trapbase_cpu2[];
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 1ee393abc463..7d5e423c186d 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -463,8 +463,5 @@ static const struct sparc32_ipi_ops leon_ipi_ops = {
 
 void __init leon_init_smp(void)
 {
-   /* Patch ipi15 trap table */
-   t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_leon - linux_trap_ipi15_sun4m);
-
sparc32_ipi_ops = _ipi_ops;
 }
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 25fe0a061732..d952bcbbc395 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -354,17 +354,

[PATCH v2 04/28] sparc32: Drop sun4m specific led driver

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The led driver is only relevant for the sun4m machines.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig |   9 ---
 arch/sparc/kernel/Makefile |   1 -
 arch/sparc/kernel/led.c| 146 -
 3 files changed, 156 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 278452f22f75..df88ad5df470 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -327,15 +327,6 @@ config SUN_PM
  Enable power management and CPU standby features on supported
  SPARC platforms.
 
-config SPARC_LED
-   tristate "Sun4m LED driver"
-   depends on SPARC32
-   help
- This driver toggles the front-panel LED on sun4m systems
- in a user-specifiable manner.  Its state can be probed
- by reading /proc/led and its blinking mode can be changed
- via writes to /proc/led
-
 config SERIAL_CONSOLE
bool
depends on SPARC32
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 58ea4ef9b622..d3a0e0ebcfe7 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -89,7 +89,6 @@ obj-y += termios.o
 
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_MODULES) += sparc_ksyms.o
-obj-$(CONFIG_SPARC_LED)   += led.o
 obj-$(CONFIG_KGDB)+= kgdb_$(BITS).o
 
 obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c
deleted file mode 100644
index ab657b359789..
--- a/arch/sparc/kernel/led.c
+++ /dev/null
@@ -1,146 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#define LED_MAX_LENGTH 8 /* maximum chars written to proc file */
-
-static inline void led_toggle(void)
-{
-   unsigned char val = get_auxio();
-   unsigned char on, off;
-
-   if (val & AUXIO_LED) {
-   on = 0;
-   off = AUXIO_LED;
-   } else {
-   on = AUXIO_LED;
-   off = 0;
-   }
-
-   set_auxio(on, off);
-}
-
-static struct timer_list led_blink_timer;
-static unsigned long led_blink_timer_timeout;
-
-static void led_blink(struct timer_list *unused)
-{
-   unsigned long timeout = led_blink_timer_timeout;
-
-   led_toggle();
-
-   /* reschedule */
-   if (!timeout) { /* blink according to load */
-   led_blink_timer.expires = jiffies +
-   ((1 + (avenrun[0] >> FSHIFT)) * HZ);
-   } else { /* blink at user specified interval */
-   led_blink_timer.expires = jiffies + (timeout * HZ);
-   }
-   add_timer(_blink_timer);
-}
-
-#ifdef CONFIG_PROC_FS
-static int led_proc_show(struct seq_file *m, void *v)
-{
-   if (get_auxio() & AUXIO_LED)
-   seq_puts(m, "on\n");
-   else
-   seq_puts(m, "off\n");
-   return 0;
-}
-
-static int led_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, led_proc_show, NULL);
-}
-
-static ssize_t led_proc_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
-   char *buf = NULL;
-
-   if (count > LED_MAX_LENGTH)
-   count = LED_MAX_LENGTH;
-
-   buf = memdup_user_nul(buffer, count);
-   if (IS_ERR(buf))
-   return PTR_ERR(buf);
-
-   /* work around \n when echo'ing into proc */
-   if (buf[count - 1] == '\n')
-   buf[count - 1] = '\0';
-
-   /* before we change anything we want to stop any running timers,
-* otherwise calls such as on will have no persistent effect
-*/
-   del_timer_sync(_blink_timer);
-
-   if (!strcmp(buf, "on")) {
-   auxio_set_led(AUXIO_LED_ON);
-   } else if (!strcmp(buf, "toggle")) {
-   led_toggle();
-   } else if ((*buf > '0') && (*buf <= '9')) {
-   led_blink_timer_timeout = simple_strtoul(buf, NULL, 10);
-   led_blink(_blink_timer);
-   } else if (!strcmp(buf, "load")) {
-   led_blink_timer_timeout = 0;
-   led_blink(_blink_timer);
-   } else {
-   auxio_set_led(AUXIO_LED_OFF);
-   }
-
-   kfree(buf);
-
-   return count;
-}
-
-static const struct proc_ops led_proc_ops = {
-   .proc_open  = led_proc_open,
-   .proc_read  = seq_read,
-   .proc_lseek = seq_lseek,
-   .proc_release   = single_release,
-   .proc_write = led_proc_write,
-};
-#endif
-
-#define LED_VERSION"0.1"
-
-static int __init led_init(void)
-{
-   timer_setup(_blink_timer, led_blink, 0);
-
-#ifdef CONFIG_PROC_FS
-   if (!proc_create(&

[PATCH v2 18/28] sparc32: Drop run-time patching of ASI instructions

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

With only LEON supported there is no need to run-time patch
the instructions to match ASI.

Move a few functions back to C with inline asm, now that
run-time patching is not needed.

Deleted a few functions that turns out not to be used rather
than re-implement them in C.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/asmmacro.h | 22 ---
 arch/sparc/include/asm/pgtsrmmu.h | 28 ++---
 arch/sparc/include/asm/sections.h |  3 --
 arch/sparc/kernel/entry.S |  7 +---
 arch/sparc/kernel/etrap_32.S  | 15 +++
 arch/sparc/kernel/rtrap_32.S  | 18 +++--
 arch/sparc/kernel/vmlinux.lds.S   |  5 ---
 arch/sparc/kernel/wof.S   | 18 +++--
 arch/sparc/kernel/wuf.S   | 21 --
 arch/sparc/mm/Makefile|  1 -
 arch/sparc/mm/srmmu_access.S  | 83 ---
 11 files changed, 40 insertions(+), 181 deletions(-)

diff --git a/arch/sparc/include/asm/asmmacro.h 
b/arch/sparc/include/asm/asmmacro.h
index 49aaf6f3bc55..d5782dbc7810 100644
--- a/arch/sparc/include/asm/asmmacro.h
+++ b/arch/sparc/include/asm/asmmacro.h
@@ -21,26 +21,4 @@
 /* All traps low-level code here must end with this macro. */
 #define RESTORE_ALL b ret_trap_entry; clr %l6;
 
-/* Support for run-time patching of single instructions.
- * This is used to handle the differences in the ASI for
- * MMUREGS for LEON and SUN.
- *
- * Sample:
- * LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %o0
- * SUN_PI_(lda [%g0] ASI_M_MMUREGS, %o0
- * PI == Patch Instruction
- *
- * For LEON we will use the first variant,
- * and for all other we will use the SUN variant.
- * The order is important.
- */
-#define LEON_PI(...)   \
-662:   __VA_ARGS__
-
-#define SUN_PI_(...)   \
-   .section .leon_1insn_patch, "ax";   \
-   .word 662b; \
-   __VA_ARGS__;\
-   .previous
-
 #endif /* !(_SPARC_ASMMACRO_H) */
diff --git a/arch/sparc/include/asm/pgtsrmmu.h 
b/arch/sparc/include/asm/pgtsrmmu.h
index 7cb5cbc83211..69c28ff3c4c4 100644
--- a/arch/sparc/include/asm/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
@@ -107,22 +107,22 @@ extern void *srmmu_nocache_pool;
 #define __nocache_va(PADDR) (__va((unsigned long)PADDR) - (unsigned 
long)srmmu_nocache_pool + SRMMU_NOCACHE_VADDR)
 #define __nocache_fix(VADDR) ((__typeof__(VADDR))__va(__nocache_pa(VADDR)))
 
-/* Accessing the MMU control register. */
-unsigned int srmmu_get_mmureg(void);
-void srmmu_set_mmureg(unsigned long regval);
-void srmmu_set_ctable_ptr(unsigned long paddr);
-void srmmu_set_context(int context);
-int srmmu_get_context(void);
-unsigned int srmmu_get_fstatus(void);
-unsigned int srmmu_get_faddr(void);
-
-/* This is guaranteed on all SRMMU's. */
-static inline void srmmu_flush_whole_tlb(void)
+static inline void srmmu_set_ctable_ptr(unsigned long paddr)
 {
-   __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
-"r" (0x400),/* Flush entire TLB!! */
-"i" (ASI_M_FLUSH_PROBE) : "memory");
+   paddr = ((paddr >> 4) & SRMMU_CTX_PMASK);
+   asm volatile("sta %0, [%1] %2\n\t" : : "r" (paddr), "r" 
(SRMMU_CTXTBL_PTR), "i" (ASI_LEON_MMUREGS) : "memory");
+}
 
+static inline void srmmu_set_context(int context)
+{
+   asm volatile("sta %0, [%1] %2\n\t" : : "r" (context), "r" 
(SRMMU_CTX_REG), "i" (ASI_LEON_MMUREGS) : "memory");
+}
+
+static inline int srmmu_get_context(void)
+{
+   register int retval;
+   asm volatile("lda [%1] %2, %0\n\t" : "=r" (retval) : "r" 
(SRMMU_CTX_REG), "i" (ASI_LEON_MMUREGS));
+   return retval;
 }
 
 #endif /* !(__ASSEMBLY__) */
diff --git a/arch/sparc/include/asm/sections.h 
b/arch/sparc/include/asm/sections.h
index 08f833453ab3..e9d28148850b 100644
--- a/arch/sparc/include/asm/sections.h
+++ b/arch/sparc/include/asm/sections.h
@@ -8,7 +8,4 @@
 /* sparc entry point */
 extern char _start[];
 
-extern char __leon_1insn_patch[];
-extern char __leon_1insn_patch_end[];
-
 #endif
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index f158cbca3e62..18c67b4fb017 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -469,11 +469,8 @@ srmmu_fault:
mov 0x400, %l5
mov 0x300, %l4
 
-LEON_PI(lda[%l5] ASI_LEON_MMUREGS, %l6)! read sfar first
-SUN_PI_(lda[%l5] ASI_M_MMUREGS, %l6)   ! read sfar first
-
-LEON_PI(lda[%l4] ASI_LEON_MMUREGS, %l5)! read sfsr last
-SUN_PI_(lda[%l4] ASI_M_MMUREGS, %l5)   ! read sfsr last
+   lda [%l5] ASI_LEON_MMUREGS, %l6 ! read sfar first
+   lda

[PATCH v2 26/28] sparc32: Drop sbus support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

LEON do not have an sbus - so drop support for that for sparc32.
Fix a few Kconfig expressions to use CONFIG_SBUS rather than SPARC
as only SPARC64 has an sbus now.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig   |  4 +-
 arch/sparc/include/asm/fb.h  |  8 ++--
 arch/sparc/include/asm/io_32.h   | 83 
 arch/sparc/kernel/ioport.c   | 49 
 arch/sparc/kernel/of_device_32.c | 14 ---
 drivers/video/fbdev/Kconfig  |  2 +-
 sound/sparc/Kconfig  |  1 +
 7 files changed, 9 insertions(+), 152 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index e4e2548c1f1f..e7a62cc06c51 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -388,11 +388,11 @@ endmenu
 menu "Bus options (PCI etc.)"
 config SBUS
bool
-   default y
+   default y if SPARC64
 
 config SBUSCHAR
bool
-   default y
+   default y if SPARC64
 
 config SUN_LDOMS
bool "Sun Logical Domains support"
diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
index 24440c0fda49..15b007875457 100644
--- a/arch/sparc/include/asm/fb.h
+++ b/arch/sparc/include/asm/fb.h
@@ -8,6 +8,9 @@
 
 struct fb_info;
 
+int fb_is_primary_device(struct fb_info *info);
+#define fb_is_primary_device fb_is_primary_device
+
 #ifdef CONFIG_SPARC32
 static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
  unsigned long vm_start, unsigned long 
vm_end,
@@ -18,9 +21,7 @@ static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
 #define pgprot_framebuffer pgprot_framebuffer
 #endif
 
-int fb_is_primary_device(struct fb_info *info);
-#define fb_is_primary_device fb_is_primary_device
-
+#ifdef CONFIG_SPARC64
 static inline void fb_memcpy_fromio(void *to, const volatile void __iomem 
*from, size_t n)
 {
sbus_memcpy_fromio(to, from, n);
@@ -38,6 +39,7 @@ static inline void fb_memset_io(volatile void __iomem *addr, 
int c, size_t n)
sbus_memset_io(addr, c, n);
 }
 #define fb_memset fb_memset_io
+#endif
 
 #include 
 
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 83abe709d120..b9f280ee1b11 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -56,78 +56,6 @@ static inline void _memcpy_toio(volatile void __iomem *dst, 
const void *src,
}
 }
 
-/*
- * SBus accessors.
- *
- * SBus has only one, memory mapped, I/O space.
- * We do not need to flip bytes for SBus of course.
- */
-static inline u8 sbus_readb(const volatile void __iomem *addr)
-{
-   return *(__force volatile u8 *)addr;
-}
-
-static inline u16 sbus_readw(const volatile void __iomem *addr)
-{
-   return *(__force volatile u16 *)addr;
-}
-
-static inline u32 sbus_readl(const volatile void __iomem *addr)
-{
-   return *(__force volatile u32 *)addr;
-}
-
-static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
-{
-   *(__force volatile u8 *)addr = b;
-}
-
-static inline void sbus_writew(u16 w, volatile void __iomem *addr)
-{
-   *(__force volatile u16 *)addr = w;
-}
-
-static inline void sbus_writel(u32 l, volatile void __iomem *addr)
-{
-   *(__force volatile u32 *)addr = l;
-}
-
-static inline void sbus_memset_io(volatile void __iomem *__dst, int c,
-  __kernel_size_t n)
-{
-   while(n--) {
-   sbus_writeb(c, __dst);
-   __dst++;
-   }
-}
-
-static inline void sbus_memcpy_fromio(void *dst,
-  const volatile void __iomem *src,
-  __kernel_size_t n)
-{
-   char *d = dst;
-
-   while (n--) {
-   char tmp = sbus_readb(src);
-   *d++ = tmp;
-   src++;
-   }
-}
-
-static inline void sbus_memcpy_toio(volatile void __iomem *dst,
-const void *src,
-__kernel_size_t n)
-{
-   const char *s = src;
-   volatile void __iomem *d = dst;
-
-   while (n--) {
-   char tmp = *s++;
-   sbus_writeb(tmp, d);
-   d++;
-   }
-}
-
 /* Create a virtual mapping cookie for an IO port range */
 void __iomem *ioport_map(unsigned long port, unsigned int nr);
 void ioport_unmap(void __iomem *);
@@ -136,17 +64,6 @@ void ioport_unmap(void __iomem *);
 struct pci_dev;
 void pci_iounmap(struct pci_dev *dev, void __iomem *);
 
-static inline int sbus_can_dma_64bit(void)
-{
-   return 0;
-}
-static inline int sbus_can_burst64(void)
-{
-   return 0;
-}
-struct device;
-void sbus_set_sbus64(struct device *, int);
-
 #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
 
 
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9c4c72775274..97b836f3be25 100644
--- a/ar

[PATCH v2 28/28] fbdev/p9100: Drop now unused driver p9100

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The p9100 driver is only relevant for the Sparcbook 3 machine,
and with sun4m support removed this driver is no longer relevant.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Acked-by: Thomas Zimmermann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
Cc: Helge Deller 
---
 drivers/video/fbdev/Kconfig  |   8 -
 drivers/video/fbdev/Makefile |   1 -
 drivers/video/fbdev/p9100.c  | 372 ---
 3 files changed, 381 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index a74f7fd3ba0c..9f1d365ed040 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -550,14 +550,6 @@ config FB_CG14
  This is the frame buffer device driver for the CGfourteen frame
  buffer on Desktop SPARCsystems with the SX graphics option.
 
-config FB_P9100
-   bool "P9100 (Sparcbook 3 only) support"
-   depends on FB_SBUS
-   select FB_SBUS_HELPERS
-   help
- This is the frame buffer device driver for the P9100 card
- supported on Sparcbook 3 machines.
-
 config FB_LEO
bool "Leo (ZX) support"
depends on FB_SBUS
diff --git a/drivers/video/fbdev/Makefile b/drivers/video/fbdev/Makefile
index 3eecd51267fa..3f4ac048d355 100644
--- a/drivers/video/fbdev/Makefile
+++ b/drivers/video/fbdev/Makefile
@@ -50,7 +50,6 @@ obj-$(CONFIG_FB_CG6)  += cg6.o
 obj-$(CONFIG_FB_CG3)  += cg3.o
 obj-$(CONFIG_FB_BW2)  += bw2.o
 obj-$(CONFIG_FB_CG14) += cg14.o
-obj-$(CONFIG_FB_P9100)+= p9100.o
 obj-$(CONFIG_FB_TCX)  += tcx.o
 obj-$(CONFIG_FB_LEO)  += leo.o
 obj-$(CONFIG_FB_ACORN)+= acornfb.o
diff --git a/drivers/video/fbdev/p9100.c b/drivers/video/fbdev/p9100.c
deleted file mode 100644
index e1356f8a866e..
--- a/drivers/video/fbdev/p9100.c
+++ /dev/null
@@ -1,372 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* p9100.c: P9100 frame buffer driver
- *
- * Copyright (C) 2003, 2006 David S. Miller (da...@davemloft.net)
- * Copyright 1999 Derrick J Brashear (sha...@dementia.org)
- *
- * Driver layout based loosely on tgafb.c, see that file for credits.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-
-#include "sbuslib.h"
-
-/*
- * Local functions.
- */
-
-static int p9100_setcolreg(unsigned, unsigned, unsigned, unsigned,
-  unsigned, struct fb_info *);
-static int p9100_blank(int, struct fb_info *);
-
-static int p9100_sbusfb_mmap(struct fb_info *info, struct vm_area_struct *vma);
-static int p9100_sbusfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned 
long arg);
-
-/*
- *  Frame buffer operations
- */
-
-static const struct fb_ops p9100_ops = {
-   .owner  = THIS_MODULE,
-   FB_DEFAULT_SBUS_OPS(p9100),
-   .fb_setcolreg   = p9100_setcolreg,
-   .fb_blank   = p9100_blank,
-};
-
-/* P9100 control registers */
-#define P9100_SYSCTL_OFF   0x0UL
-#define P9100_VIDEOCTL_OFF 0x100UL
-#define P9100_VRAMCTL_OFF  0x180UL
-#define P9100_RAMDAC_OFF   0x200UL
-#define P9100_VIDEOCOPROC_OFF  0x400UL
-
-/* P9100 command registers */
-#define P9100_CMD_OFF 0x0UL
-
-/* P9100 framebuffer memory */
-#define P9100_FB_OFF 0x0UL
-
-/* 3 bits: 2=8bpp 3=16bpp 5=32bpp 7=24bpp */
-#define SYS_CONFIG_PIXELSIZE_SHIFT 26
-
-#define SCREENPAINT_TIMECTL1_ENABLE_VIDEO 0x20 /* 0 = off, 1 = on */
-
-struct p9100_regs {
-   /* Registers for the system control */
-   u32 sys_base;
-   u32 sys_config;
-   u32 sys_intr;
-   u32 sys_int_ena;
-   u32 sys_alt_rd;
-   u32 sys_alt_wr;
-   u32 sys_xxx[58];
-
-   /* Registers for the video control */
-   u32 vid_base;
-   u32 vid_hcnt;
-   u32 vid_htotal;
-   u32 vid_hsync_rise;
-   u32 vid_hblank_rise;
-   u32 vid_hblank_fall;
-   u32 vid_hcnt_preload;
-   u32 vid_vcnt;
-   u32 vid_vlen;
-   u32 vid_vsync_rise;
-   u32 vid_vblank_rise;
-   u32 vid_vblank_fall;
-   u32 vid_vcnt_preload;
-   u32 vid_screenpaint_addr;
-   u32 vid_screenpaint_timectl1;
-   u32 vid_screenpaint_qsfcnt;
-   u32 vid_screenpaint_timectl2;
-   u32 vid_xxx[15];
-
-   /* Registers for the video control */
-   u32 vram_base;
-   u32 vram_memcfg;
-   u32 vram_refresh_pd;
-   u32 vram_refresh_cnt;
-   u32 vram_raslo_max;
-   u32 vram_raslo_cur;
-   u32 pwrup_cfg;
-   u32 vram_xxx[25];
-
-   /* Registers for IBM RGB528 Palette */
-   u32 ramdac_cmap_wridx;
-   u32 ramdac_palette_data;
-   u32 ramdac_pixel_mask;
-   u32 ramdac_palette_rdaddr;
-   u32 ramdac_idx_lo;
-   u32 ramdac_idx_hi;
-   u32 ramdac_idx_data;
-   u32 ramdac_idx_ctl;
-   u32 ramdac_xxx[1784];
-};
-

[PATCH v2 06/28] sparc32: Drop auxio support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

auxio is not supported by LEON - so drop it.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/auxio_32.h |  73 +---
 arch/sparc/kernel/Makefile|   2 +-
 arch/sparc/kernel/auxio_32.c  | 139 --
 arch/sparc/kernel/devices.c   |   3 -
 arch/sparc/kernel/kernel.h|   4 --
 arch/sparc/kernel/process_32.c|  10 ---
 arch/sparc/prom/misc_32.c |   2 -
 7 files changed, 3 insertions(+), 230 deletions(-)

diff --git a/arch/sparc/include/asm/auxio_32.h 
b/arch/sparc/include/asm/auxio_32.h
index 852457c7a265..e2335ddd359d 100644
--- a/arch/sparc/include/asm/auxio_32.h
+++ b/arch/sparc/include/asm/auxio_32.h
@@ -1,43 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * auxio.h:  Definitions and code for the Auxiliary I/O register.
+ * Dummy definitions for the Auxiliary I/O register.
  *
  * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
  */
 #ifndef _SPARC_AUXIO_H
 #define _SPARC_AUXIO_H
 
-#include 
-
-/* This register is an unsigned char in IO space.  It does two things.
- * First, it is used to control the front panel LED light on machines
- * that have it (good for testing entry points to trap handlers and irq's)
- * Secondly, it controls various floppy drive parameters.
- */
-#define AUXIO_ORMEIN  0xf0/* All writes must set these bits. */
-#define AUXIO_ORMEIN4M0xc0/* sun4m - All writes must set these bits. */
-#define AUXIO_FLPY_DENS   0x20/* Floppy density, high if set. Read only. */
-#define AUXIO_FLPY_DCHG   0x10/* A disk change occurred.  Read only. */
-#define AUXIO_EDGE_ON 0x10/* sun4m - On means Jumper block is in. */
-#define AUXIO_FLPY_DSEL   0x08/* Drive select/start-motor. Write only. */
-#define AUXIO_LINK_TEST   0x08/* sun4m - On means TPE Carrier detect. */
-
-/* Set the following to one, then zero, after doing a pseudo DMA transfer. */
-#define AUXIO_FLPY_TCNT   0x04/* Floppy terminal count. Write only. */
-
-/* Set the following to zero to eject the floppy. */
-#define AUXIO_FLPY_EJCT   0x02/* Eject floppy disk.  Write only. */
-#define AUXIO_LED 0x01/* On if set, off if unset. Read/Write */
-
-#ifndef __ASSEMBLY__
-
-/*
- * NOTE: these routines are implementation dependent--
- * understand the hardware you are querying!
- */
-void set_auxio(unsigned char bits_on, unsigned char bits_off);
-unsigned char get_auxio(void); /* .../asm/floppy.h */
-
 /*
  * The following routines are provided for driver-compatibility
  * with sparc64 (primarily sunlance.c)
@@ -46,44 +15,6 @@ unsigned char get_auxio(void); /* .../asm/floppy.h */
 #define AUXIO_LTE_ON1
 #define AUXIO_LTE_OFF   0
 
-/* auxio_set_lte - Set Link Test Enable (TPE Link Detect)
- *
- * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
- */
-#define auxio_set_lte(on) \
-do { \
-   if(on) { \
-   set_auxio(AUXIO_LINK_TEST, 0); \
-   } else { \
-   set_auxio(0, AUXIO_LINK_TEST); \
-   } \
-} while (0)
-
-#define AUXIO_LED_ON1
-#define AUXIO_LED_OFF   0
-
-/* auxio_set_led - Set system front panel LED
- *
- * on - AUXIO_LED_ON or AUXIO_LED_OFF
- */
-#define auxio_set_led(on) \
-do { \
-   if(on) { \
-   set_auxio(AUXIO_LED, 0); \
-   } else { \
-   set_auxio(0, AUXIO_LED); \
-   } \
-} while (0)
-
-#endif /* !(__ASSEMBLY__) */
-
-
-/* AUXIO2 (Power Off Control) */
-extern volatile u8 __iomem *auxio_power_register;
-
-#defineAUXIO_POWER_DETECT_FAILURE  32
-#defineAUXIO_POWER_CLEAR_FAILURE   2
-#defineAUXIO_POWER_OFF 1
-
+#define auxio_set_lte(on)
 
 #endif /* !(_SPARC_AUXIO_H) */
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 1a942546dd00..b253b7e132ce 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -82,7 +82,7 @@ obj-$(CONFIG_SMP) += trampoline_$(BITS).o 
smp_$(BITS).o
 obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
-obj-y += auxio_$(BITS).o
+obj-$(CONFIG_SPARC64) += auxio_64.o
 
 obj-y += termios.o
 
diff --git a/arch/sparc/kernel/auxio_32.c b/arch/sparc/kernel/auxio_32.c
deleted file mode 100644
index 989860e890c4..
--- a/arch/sparc/kernel/auxio_32.c
+++ /dev/null
@@ -1,139 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* auxio.c: Probing for the Sparc AUXIO register at boot time.
- *
- * Copyright (C) 1996 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include /* memset(), Linux has no bzero() */
-#include 
-
-#include "kernel.h"
-
-/* Probe and map in the Auxiliary I/O register */
-
-/* auxio_register is not static because it is referenced 
- * in e

[PATCH v2 11/28] sparc32: Drop pcic support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

pcic is only used by MicroSPARC-IIep and not relevant for LEON.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig|   5 -
 arch/sparc/include/asm/pcic.h | 130 ---
 arch/sparc/kernel/Makefile|   1 -
 arch/sparc/kernel/entry.S |  48 ---
 arch/sparc/kernel/irq_32.c|   1 -
 arch/sparc/kernel/kernel.h|   4 -
 arch/sparc/kernel/pcic.c  | 829 --
 arch/sparc/kernel/time_32.c   |   6 +-
 8 files changed, 1 insertion(+), 1023 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 23cdf1959991..19ee7bc0b2ea 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -410,11 +410,6 @@ config SUN_LDOMS
  Say Y here is you want to support virtual devices via
  Logical Domains.
 
-config PCIC_PCI
-   bool
-   depends on PCI && SPARC32 && !SPARC_LEON
-   default y
-
 config LEON_PCI
bool
depends on PCI && SPARC_LEON
diff --git a/arch/sparc/include/asm/pcic.h b/arch/sparc/include/asm/pcic.h
deleted file mode 100644
index 238376b1ffcc..
--- a/arch/sparc/include/asm/pcic.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * pcic.h: JavaEngine 1 specific PCI definitions.
- *
- * Copyright (C) 1998 V. Roganov and G. Raiko
- */
-
-#ifndef __SPARC_PCIC_H
-#define __SPARC_PCIC_H
-
-#ifndef __ASSEMBLY__
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-struct linux_pcic {
-void __iomem*pcic_regs;
-unsigned long   pcic_io;
-void __iomem*pcic_config_space_addr;
-void __iomem*pcic_config_space_data;
-   struct resource pcic_res_regs;
-   struct resource pcic_res_io;
-   struct resource pcic_res_cfg_addr;
-   struct resource pcic_res_cfg_data;
-struct linux_pbm_info   pbm;
-   struct pcic_ca2irq  *pcic_imap;
-   int pcic_imdim;
-};
-
-#ifdef CONFIG_PCIC_PCI
-int pcic_present(void);
-int pcic_probe(void);
-void pci_time_init(void);
-void sun4m_pci_init_IRQ(void);
-#else
-static inline int pcic_present(void) { return 0; }
-static inline int pcic_probe(void) { return 0; }
-static inline void pci_time_init(void) {}
-static inline void sun4m_pci_init_IRQ(void) {}
-#endif
-#endif
-
-/* Size of PCI I/O space which we relocate. */
-#define PCI_SPACE_SIZE  0x100   /* 16 MB */
-
-/* PCIC Register Set. */
-#define PCI_DIAGNOSTIC_00x40/* 32 bits */
-#define PCI_SIZE_0  0x44/* 32 bits */
-#define PCI_SIZE_1  0x48/* 32 bits */
-#define PCI_SIZE_2  0x4c/* 32 bits */
-#define PCI_SIZE_3  0x50/* 32 bits */
-#define PCI_SIZE_4  0x54/* 32 bits */
-#define PCI_SIZE_5  0x58/* 32 bits */
-#define PCI_PIO_CONTROL 0x60/* 8  bits */
-#define PCI_DVMA_CONTROL0x62/* 8  bits */
-#define  PCI_DVMA_CONTROL_INACTIVITY_REQ(1<<0)
-#define  PCI_DVMA_CONTROL_IOTLB_ENABLE  (1<<0)
-#define  PCI_DVMA_CONTROL_IOTLB_DISABLE 0
-#define  PCI_DVMA_CONTROL_INACTIVITY_ACK(1<<4)
-#define PCI_INTERRUPT_CONTROL   0x63/* 8  bits */
-#define PCI_CPU_INTERRUPT_PENDING   0x64/* 32 bits */
-#define PCI_DIAGNOSTIC_10x68/* 16 bits */
-#define PCI_SOFTWARE_INT_CLEAR  0x6a/* 16 bits */
-#define PCI_SOFTWARE_INT_SET0x6e/* 16 bits */
-#define PCI_SYS_INT_PENDING 0x70/* 32 bits */
-#define  PCI_SYS_INT_PENDING_PIO   0x4000
-#define  PCI_SYS_INT_PENDING_DMA   0x2000
-#define  PCI_SYS_INT_PENDING_PCI   0x1000
-#define  PCI_SYS_INT_PENDING_APSR  0x0800
-#define PCI_SYS_INT_TARGET_MASK 0x74/* 32 bits */
-#define PCI_SYS_INT_TARGET_MASK_CLEAR   0x78/* 32 bits */
-#define PCI_SYS_INT_TARGET_MASK_SET 0x7c/* 32 bits */
-#define PCI_SYS_INT_PENDING_CLEAR   0x83/* 8  bits */
-#define  PCI_SYS_INT_PENDING_CLEAR_ALL 0x80
-#define  PCI_SYS_INT_PENDING_CLEAR_PIO 0x40
-#define  PCI_SYS_INT_PENDING_CLEAR_DMA 0x20
-#define  PCI_SYS_INT_PENDING_CLEAR_PCI 0x10
-#define PCI_IOTLB_CONTROL   0x84/* 8  bits */
-#define PCI_INT_SELECT_LO   0x88/* 16 bits */
-#define PCI_ARBITRATION_SELECT  0x8a/* 16 bits */
-#define PCI_INT_SELECT_HI   0x8c/* 16 bits */
-#define PCI_HW_INT_OUTPUT   0x8e/* 16 bits */
-#define PCI_IOTLB_RAM_INPUT 0x90/* 32 bits */
-#define PCI_IOTLB_CAM_INPUT 0x94/* 32 bits */
-#define PCI_IOTLB_RAM_OUTPUT   

[PATCH v2 01/28] sparc32: Update defconfig to LEON SMP

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

This is a copy of the leon_smp defconfig found in
gaisler-buildroot-2023.02-1.0.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/configs/sparc32_defconfig | 171 +++
 1 file changed, 91 insertions(+), 80 deletions(-)

diff --git a/arch/sparc/configs/sparc32_defconfig 
b/arch/sparc/configs/sparc32_defconfig
index 5010164de3e4..71273fc578bf 100644
--- a/arch/sparc/configs/sparc32_defconfig
+++ b/arch/sparc/configs/sparc32_defconfig
@@ -1,97 +1,108 @@
+CONFIG_DEFAULT_HOSTNAME="leon"
 CONFIG_SYSVIPC=y
-CONFIG_POSIX_MQUEUE=y
 CONFIG_LOG_BUF_SHIFT=14
-CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_BLK_DEV_INITRD=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_BLK_DEV_BSG is not set
-CONFIG_PCI=y
-CONFIG_SUN_OPENPROMFS=m
-CONFIG_BINFMT_MISC=m
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+# CONFIG_RD_ZSTD is not set
+CONFIG_SMP=y
+CONFIG_HZ_100=y
+CONFIG_SPARC_LEON=y
+CONFIG_SUN_OPENPROMFS=y
+CONFIG_SUN_OPENPROMIO=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_MISC=y
+# CONFIG_COMPACTION is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
-CONFIG_XFRM_USER=m
-CONFIG_NET_KEY=m
 CONFIG_INET=y
 CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_INET_AH=y
-CONFIG_INET_ESP=y
-CONFIG_INET_IPCOMP=y
-CONFIG_INET6_AH=m
-CONFIG_INET6_ESP=m
-CONFIG_INET6_IPCOMP=m
-CONFIG_IPV6_TUNNEL=m
-CONFIG_NET_PKTGEN=m
-CONFIG_BLK_DEV_LOOP=m
-CONFIG_BLK_DEV_CRYPTOLOOP=m
-CONFIG_BLK_DEV_RAM=y
-CONFIG_SCSI=y
-CONFIG_BLK_DEV_SD=y
-CONFIG_BLK_DEV_SR=m
-CONFIG_CHR_DEV_SG=m
-CONFIG_SCSI_QLOGICPTI=m
-CONFIG_SCSI_SUNESP=y
+# CONFIG_WIRELESS is not set
+CONFIG_UEVENT_HELPER=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_NETDEVICES=y
-CONFIG_DUMMY=m
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=m
-CONFIG_SUNLANCE=y
-CONFIG_HAPPYMEAL=m
-CONFIG_SUNBMAC=m
-CONFIG_SUNQE=m
+CONFIG_GRETH=y
+# CONFIG_NET_VENDOR_ALACRITECH is not set
+# CONFIG_NET_VENDOR_AMAZON is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_AQUANTIA is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CADENCE is not set
+# CONFIG_NET_VENDOR_CAVIUM is not set
+# CONFIG_NET_VENDOR_CORTINA is not set
+# CONFIG_NET_VENDOR_EZCHIP is not set
+# CONFIG_NET_VENDOR_GOOGLE is not set
+# CONFIG_NET_VENDOR_HUAWEI is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_MICROSEMI is not set
+# CONFIG_NET_VENDOR_NI is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_NET_VENDOR_PENSANDO is not set
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_RENESAS is not set
+# CONFIG_NET_VENDOR_ROCKER is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
+# CONFIG_NET_VENDOR_SOCIONEXT is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_SUN is not set
+# CONFIG_NET_VENDOR_SYNOPSYS is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+# CONFIG_NET_VENDOR_XILINX is not set
+CONFIG_BROADCOM_PHY=y
+CONFIG_CICADA_PHY=y
+CONFIG_DAVICOM_PHY=y
+CONFIG_ICPLUS_PHY=y
+CONFIG_LXT_PHY=y
+CONFIG_LSI_ET1011C_PHY=y
+CONFIG_MARVELL_PHY=y
+CONFIG_MICREL_PHY=y
+CONFIG_NATIONAL_PHY=y
+CONFIG_QSEMI_PHY=y
+CONFIG_REALTEK_PHY=y
+CONFIG_SMSC_PHY=y
+CONFIG_STE10XP=y
+CONFIG_VITESSE_PHY=y
 # CONFIG_WLAN is not set
-CONFIG_INPUT_JOYDEV=m
-CONFIG_INPUT_EVDEV=m
-CONFIG_INPUT_EVBUG=m
-CONFIG_KEYBOARD_ATKBD=m
-CONFIG_KEYBOARD_SUNKBD=m
-CONFIG_MOUSE_PS2=m
-CONFIG_MOUSE_SERIAL=m
-CONFIG_SERIO=m
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIAL_SUNZILOG=y
 CONFIG_SERIAL_SUNZILOG_CONSOLE=y
-CONFIG_SERIAL_SUNSU=y
-CONFIG_SERIAL_SUNSU_CONSOLE=y
-CONFIG_SPI=y
-CONFIG_SPI_XILINX=m
-CONFIG_SPI_XILINX_PLTFM=m
-CONFIG_SUN_OPENPROMIO=m
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-CONFIG_EXT2_FS_SECURITY=y
-CONFIG_AUTOFS_FS=m
-CONFIG_ISO9660_FS=m
+CONFIG_SERIAL_GRLIB_GAISLER_APBUART=y
+CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_HID_GENERIC is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_RTC_HCTOSYS is not set
+# CONFIG_RTC_INTF_SYSFS is not set
+# CONFIG_RTC_INTF_PROC is not set
+# CONFIG_RTC_INTF_DEV is not set
+# CONFIG_VIRTIO_MENU is not set
+# CONFIG_VHOST_MENU is not set
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_FSCACHE=y
 CONFIG_PROC_KCORE=y
-CONFIG_ROMFS_FS=m
+CONFIG_TMPFS=y
+# CONFIG_MISC_FILESYSTEMS is not set
 CONFIG_NFS_FS=y
+CONFIG_NFS_V4=y
 CONFIG_ROOT_NFS=y
-CONF

[PATCH v2 15/28] sparc32: Drop check for sparc_model

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

sparc32 is always LEON, so no need to check for the model.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/cpu_type.h | 18 -
 arch/sparc/include/asm/io_32.h|  4 +-
 arch/sparc/kernel/devices.c   |  7 +---
 arch/sparc/kernel/ioport.c|  4 +-
 arch/sparc/kernel/leon_pmc.c  | 16 
 arch/sparc/kernel/setup_32.c  | 79 +--
 6 files changed, 12 insertions(+), 116 deletions(-)

diff --git a/arch/sparc/include/asm/cpu_type.h 
b/arch/sparc/include/asm/cpu_type.h
index 2b59799859d1..3e0154c3f41d 100644
--- a/arch/sparc/include/asm/cpu_type.h
+++ b/arch/sparc/include/asm/cpu_type.h
@@ -2,28 +2,10 @@
 #ifndef __ASM_CPU_TYPE_H
 #define __ASM_CPU_TYPE_H
 
-/*
- * Sparc (general) CPU types
- */
-enum sparc_cpu {
-  sun4m   = 0x00,
-  sun4d   = 0x01,
-  sun4e   = 0x02,
-  sun4u   = 0x03, /* V8 ploos ploos */
-  sun_unknown = 0x04,
-  ap1000  = 0x05, /* almost a sun4m */
-  sparc_leon  = 0x06, /* Leon SoC */
-};
-
 #ifdef CONFIG_SPARC32
-extern enum sparc_cpu sparc_cpu_model;
 
 #define SUN4M_NCPUS4  /* Architectural limit of sun4m. 
*/
 
-#else
-
-#define sparc_cpu_model sun4u
-
 #endif
 
 #endif /* __ASM_CPU_TYPE_H */
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 549f0a72280d..83abe709d120 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -138,11 +138,11 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *);
 
 static inline int sbus_can_dma_64bit(void)
 {
-   return 0; /* actually, sparc_cpu_model==sun4d */
+   return 0;
 }
 static inline int sbus_can_burst64(void)
 {
-   return 0; /* actually, sparc_cpu_model==sun4d */
+   return 0;
 }
 struct device;
 void sbus_set_sbus64(struct device *, int);
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index b3c2d51b22c4..2963e89611a3 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -26,8 +26,6 @@
 
 static char *cpu_mid_prop(void)
 {
-   if (sparc_cpu_model == sun4d)
-   return "cpu-id";
return "mid";
 }
 
@@ -40,8 +38,6 @@ static int check_cpu_node(phandle nd, int *cur_inst,
*prom_node = nd;
if (mid) {
*mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
-   if (sparc_cpu_model == sun4m)
-   *mid &= 3;
}
return 0;
}
@@ -92,8 +88,7 @@ static int cpu_mid_compare(phandle nd, int instance, void 
*_arg)
int this_mid;
 
this_mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
-   if (this_mid == desired_mid
-   || (sparc_cpu_model == sun4m && (this_mid & 3) == desired_mid))
+   if (this_mid == desired_mid)
return 0;
return -ENODEV;
 }
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 5ebca5c7af1e..cf0ace29704a 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -309,9 +309,7 @@ arch_initcall(sparc_register_ioport);
 void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
enum dma_data_direction dir)
 {
-   if (dir != DMA_TO_DEVICE &&
-   sparc_cpu_model == sparc_leon &&
-   !sparc_leon3_snooping_enabled())
+   if (dir != DMA_TO_DEVICE && !sparc_leon3_snooping_enabled())
leon_flush_dcache_all();
 }
 
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c
index 6c00cbad7fb5..d4a2d49f941c 100644
--- a/arch/sparc/kernel/leon_pmc.c
+++ b/arch/sparc/kernel/leon_pmc.c
@@ -79,15 +79,13 @@ static void pmc_leon_idle(void)
 /* Install LEON Power Down function */
 static int __init leon_pmc_install(void)
 {
-   if (sparc_cpu_model == sparc_leon) {
-   /* Assign power management IDLE handler */
-   if (pmc_leon_need_fixup())
-   sparc_idle = pmc_leon_idle_fixup;
-   else
-   sparc_idle = pmc_leon_idle;
-
-   printk(KERN_INFO "leon: power management initialized\n");
-   }
+   /* Assign power management IDLE handler */
+   if (pmc_leon_need_fixup())
+   sparc_idle = pmc_leon_idle_fixup;
+   else
+   sparc_idle = pmc_leon_idle;
+
+   printk(KERN_INFO "leon: power management initialized\n");
 
return 0;
 }
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 3c6c16fde8c3..0f38d72aae2d 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -189,30 +189,12 @@ static void __init per_cpu_patch(void)
 {
struct cpuid_patch_entry *p;
 
-   if (sparc_cpu_model == sun4m) {
- 

[PATCH v2 13/28] sparc32: Drop unused function __get_{phys,iospace}

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Not used and references stuff that will be dropped later.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/pgtable_32.h | 24 
 arch/sparc/include/asm/pgtsrmmu.h   | 11 ---
 2 files changed, 35 deletions(-)

diff --git a/arch/sparc/include/asm/pgtable_32.h 
b/arch/sparc/include/asm/pgtable_32.h
index 9e85d57ac3f2..92b063531d5c 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -368,30 +368,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
return __pte(pte_val(pte) & ~SRMMU_SWP_EXCLUSIVE);
 }
 
-static inline unsigned long
-__get_phys (unsigned long addr)
-{
-   switch (sparc_cpu_model){
-   case sun4m:
-   case sun4d:
-   return ((srmmu_get_pte (addr) & 0xff00) << 4);
-   default:
-   return 0;
-   }
-}
-
-static inline int
-__get_iospace (unsigned long addr)
-{
-   switch (sparc_cpu_model){
-   case sun4m:
-   case sun4d:
-   return (srmmu_get_pte (addr) >> 28);
-   default:
-   return -1;
-   }
-}
-
 /*
  * For sparc32&64, the pfn in io_remap_pfn_range() carries  in
  * its high 4 bits.  These macros/functions put it there or get it from there.
diff --git a/arch/sparc/include/asm/pgtsrmmu.h 
b/arch/sparc/include/asm/pgtsrmmu.h
index 18e68d43f036..7cb5cbc83211 100644
--- a/arch/sparc/include/asm/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
@@ -125,17 +125,6 @@ static inline void srmmu_flush_whole_tlb(void)
 
 }
 
-static inline int
-srmmu_get_pte (unsigned long addr)
-{
-   register unsigned long entry;
-
-   __asm__ __volatile__("\n\tlda [%1] %2,%0\n\t" :
-   "=r" (entry):
-   "r" ((addr & 0xf000) | 0x400), "i" 
(ASI_M_FLUSH_PROBE));
-   return entry;
-}
-
 #endif /* !(__ASSEMBLY__) */
 
 #endif /* !(_SPARC_PGTSRMMU_H) */

-- 
2.34.1



[PATCH v2 05/28] sparc32: Drop sun specific power management drivers

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the two sun specific apc and pmc drivers.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig |   7 --
 arch/sparc/kernel/Makefile |   1 -
 arch/sparc/kernel/apc.c| 196 -
 arch/sparc/kernel/pmc.c| 100 ---
 4 files changed, 304 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index df88ad5df470..23cdf1959991 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -320,13 +320,6 @@ config CMDLINE
 
  NOTE: This option WILL override the PROM bootargs setting!
 
-config SUN_PM
-   bool
-   default y if SPARC32
-   help
- Enable power management and CPU standby features on supported
- SPARC platforms.
-
 config SERIAL_CONSOLE
bool
depends on SPARC32
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index d3a0e0ebcfe7..1a942546dd00 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -83,7 +83,6 @@ obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o 
leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
 obj-y += auxio_$(BITS).o
-obj-$(CONFIG_SUN_PM)  += apc.o pmc.o
 
 obj-y += termios.o
 
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
deleted file mode 100644
index d44725d37e30..
--- a/arch/sparc/kernel/apc.c
+++ /dev/null
@@ -1,196 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* apc - Driver implementation for power management functions
- * of Aurora Personality Chip (APC) on SPARCstation-4/5 and
- * derivatives.
- *
- * Copyright (c) 2002 Eric Brower (ebro...@usa.net)
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* Debugging
- * 
- * #define APC_DEBUG_LED
- */
-
-#define APC_MINOR  MISC_DYNAMIC_MINOR
-#define APC_OBPNAME"power-management"
-#define APC_DEVNAME "apc"
-
-static u8 __iomem *regs;
-static int apc_no_idle = 0;
-
-#define apc_readb(offs)(sbus_readb(regs+offs))
-#define apc_writeb(val, offs)  (sbus_writeb(val, regs+offs))
-
-/* Specify "apc=noidle" on the kernel command line to 
- * disable APC CPU standby support.  Certain prototype
- * systems (SPARCstation-Fox) do not play well with APC
- * CPU idle, so disable this if your system has APC and 
- * crashes randomly.
- */
-static int __init apc_setup(char *str) 
-{
-   if(!strncmp(str, "noidle", strlen("noidle"))) {
-   apc_no_idle = 1;
-   return 1;
-   }
-   return 0;
-}
-__setup("apc=", apc_setup);
-
-/* 
- * CPU idle callback function
- * See .../arch/sparc/kernel/process.c
- */
-static void apc_swift_idle(void)
-{
-#ifdef APC_DEBUG_LED
-   set_auxio(0x00, AUXIO_LED); 
-#endif
-
-   apc_writeb(apc_readb(APC_IDLE_REG) | APC_IDLE_ON, APC_IDLE_REG);
-
-#ifdef APC_DEBUG_LED
-   set_auxio(AUXIO_LED, 0x00); 
-#endif
-} 
-
-static inline void apc_free(struct platform_device *op)
-{
-   of_iounmap(>resource[0], regs, resource_size(>resource[0]));
-}
-
-static int apc_open(struct inode *inode, struct file *f)
-{
-   return 0;
-}
-
-static int apc_release(struct inode *inode, struct file *f)
-{
-   return 0;
-}
-
-static long apc_ioctl(struct file *f, unsigned int cmd, unsigned long __arg)
-{
-   __u8 inarg, __user *arg = (__u8 __user *) __arg;
-
-   switch (cmd) {
-   case APCIOCGFANCTL:
-   if (put_user(apc_readb(APC_FANCTL_REG) & APC_REGMASK, arg))
-   return -EFAULT;
-   break;
-
-   case APCIOCGCPWR:
-   if (put_user(apc_readb(APC_CPOWER_REG) & APC_REGMASK, arg))
-   return -EFAULT;
-   break;
-
-   case APCIOCGBPORT:
-   if (put_user(apc_readb(APC_BPORT_REG) & APC_BPMASK, arg))
-   return -EFAULT;
-   break;
-
-   case APCIOCSFANCTL:
-   if (get_user(inarg, arg))
-   return -EFAULT;
-   apc_writeb(inarg & APC_REGMASK, APC_FANCTL_REG);
-   break;
-
-   case APCIOCSCPWR:
-   if (get_user(inarg, arg))
-   return -EFAULT;
-   apc_writeb(inarg & APC_REGMASK, APC_CPOWER_REG);
-   break;
-
-   case APCIOCSBPORT:
-   if (get_user(inarg, arg))
-   return -EFAULT;
-   apc_writeb(inarg & APC_BPMASK, APC_BPORT_REG);
-   break;
-
-   default:
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
-static const struct file_operations apc_fops = {
-   .unlocked_ioctl =   apc_ioctl,
-   .open = apc_open,
-  

[PATCH v2 03/28] sparc32: Drop floppy support

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

LEON do not have floppy support so we can drop it

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig |   2 +-
 arch/sparc/include/asm/floppy.h|   2 -
 arch/sparc/include/asm/floppy_32.h | 393 -
 arch/sparc/include/asm/setup.h |  12 --
 arch/sparc/kernel/entry.S  | 137 -
 arch/sparc/kernel/irq.h|   3 -
 arch/sparc/kernel/irq_32.c |  93 -
 arch/sparc/kernel/kernel.h |   2 -
 8 files changed, 1 insertion(+), 643 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index d08a5662ea60..278452f22f75 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -189,7 +189,7 @@ config GENERIC_CALIBRATE_DELAY
 
 config ARCH_MAY_HAVE_PC_FDC
bool
-   default y
+   default y if SPARC64
 
 config EMULATED_CMPXCHG
bool
diff --git a/arch/sparc/include/asm/floppy.h b/arch/sparc/include/asm/floppy.h
index 4b315802e635..c89f719a18e9 100644
--- a/arch/sparc/include/asm/floppy.h
+++ b/arch/sparc/include/asm/floppy.h
@@ -3,7 +3,5 @@
 #define ___ASM_SPARC_FLOPPY_H
 #if defined(__sparc__) && defined(__arch64__)
 #include 
-#else
-#include 
 #endif
 #endif
diff --git a/arch/sparc/include/asm/floppy_32.h 
b/arch/sparc/include/asm/floppy_32.h
deleted file mode 100644
index 836f6575aa1d..
--- a/arch/sparc/include/asm/floppy_32.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* asm/floppy.h: Sparc specific parts of the Floppy driver.
- *
- * Copyright (C) 1995 David S. Miller (da...@davemloft.net)
- */
-
-#ifndef __ASM_SPARC_FLOPPY_H
-#define __ASM_SPARC_FLOPPY_H
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* We don't need no stinkin' I/O port allocation crap. */
-#undef release_region
-#undef request_region
-#define release_region(X, Y)   do { } while(0)
-#define request_region(X, Y, Z)(1)
-
-/* References:
- * 1) Netbsd Sun floppy driver.
- * 2) NCR 82077 controller manual
- * 3) Intel 82077 controller manual
- */
-struct sun_flpy_controller {
-   volatile unsigned char status_82072;  /* Main Status reg. */
-#define dcr_82072  status_82072   /* Digital Control reg. */
-#define status1_82077  status_82072   /* Auxiliary Status reg. 1 */
-
-   volatile unsigned char data_82072;/* Data fifo. */
-#define status2_82077  data_82072 /* Auxiliary Status reg. 2 */
-
-   volatile unsigned char dor_82077; /* Digital Output reg. */
-   volatile unsigned char tapectl_82077; /* What the? Tape control reg? */
-
-   volatile unsigned char status_82077;  /* Main Status Register. */
-#define drs_82077  status_82077   /* Digital Rate Select reg. */
-
-   volatile unsigned char data_82077;/* Data fifo. */
-   volatile unsigned char ___unused;
-   volatile unsigned char dir_82077; /* Digital Input reg. */
-#define dcr_82077  dir_82077  /* Config Control reg. */
-};
-
-/* You'll only ever find one controller on a SparcStation anyways. */
-static struct sun_flpy_controller *sun_fdc = NULL;
-
-struct sun_floppy_ops {
-   unsigned char (*fd_inb)(int port);
-   void (*fd_outb)(unsigned char value, int port);
-};
-
-static struct sun_floppy_ops sun_fdops;
-
-#define fd_inb(base, reg) sun_fdops.fd_inb(reg)
-#define fd_outb(value, base, reg) sun_fdops.fd_outb(value, reg)
-#define fd_enable_dma()   sun_fd_enable_dma()
-#define fd_disable_dma()  sun_fd_disable_dma()
-#define fd_request_dma()  (0) /* nothing... */
-#define fd_free_dma() /* nothing... */
-#define fd_clear_dma_ff() /* nothing... */
-#define fd_set_dma_mode(mode) sun_fd_set_dma_mode(mode)
-#define fd_set_dma_addr(addr) sun_fd_set_dma_addr(addr)
-#define fd_set_dma_count(count)   sun_fd_set_dma_count(count)
-#define fd_enable_irq()   /* nothing... */
-#define fd_disable_irq()  /* nothing... */
-#define fd_request_irq()  sun_fd_request_irq()
-#define fd_free_irq() /* nothing... */
-#if 0  /* P3: added by Alain, these cause a MMU corruption. 19960524 XXX */
-#define fd_dma_mem_alloc(size)((unsigned long) vmalloc(size))
-#define fd_dma_mem_free(addr,size) (vfree((void *)(addr)))
-#endif
-
-/* XXX This isn't really correct. XXX */
-#define get_dma_residue(x)(0)
-
-#define FLOPPY0_TYPE  4
-#define FLOPPY1_TYPE  0
-
-/* Super paranoid... */
-#undef HAVE_DISABLE_HLT
-
-/* Here is where we catch the floppy driver trying to initialize,
- * therefore this is where we call the PROM device tree probing
- * routine etc. on the Sparc.
- */
-#define FDC1  sun_floppy_init()
-
-#define N_FDC1
-#define N_DRIVE  8
-
-/* No 64k boundary crossing problems on the Sparc. */
-#define 

[PATCH v2 02/28] sparc32: Drop sun4m/sun4d support from head_32.S

2024-03-09 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Remove the most obvious parts of sun4* support from head_32.S.
Use a single print if a sun4* machine is detected thus restricting
boots to LEON machines.

Signed-off-by: Sam Ravnborg 
Acked-by: Arnd Bergmann 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/head_32.S | 190 +++-
 1 file changed, 9 insertions(+), 181 deletions(-)

diff --git a/arch/sparc/kernel/head_32.S b/arch/sparc/kernel/head_32.S
index 964c61b5cd03..03dc232dd235 100644
--- a/arch/sparc/kernel/head_32.S
+++ b/arch/sparc/kernel/head_32.S
@@ -45,11 +45,7 @@ cputypvar:
.align 4
 
 notsup:
-   .asciz  "Sparc-Linux sun4/sun4c or MMU-less not supported\n\n"
-   .align 4
-
-sun4e_notsup:
-.asciz  "Sparc-Linux sun4e support does not exist\n\n"
+   .asciz  "This kernel only supports LEON SPARC V8\n\n"
.align 4
 
 /* The trap-table - located in the __HEAD section */
@@ -215,114 +211,10 @@ not_a_sun4:
be  leon_remap  /* It is a LEON - jump */
 nop
 
-   /* Sanity-check, is MMU enabled */
-   lda [%g0] ASI_M_MMUREGS, %g1
-   andcc   %g1, 1, %g0
-   be  halt_notsup
-nop
-
-   /* Check for a viking (TI) module. */
-   cmp %g3, PSR_IMPL_TI
-   bne srmmu_not_viking
-nop
-
-   /* Figure out what kind of viking we are on.
-* We need to know if we have to play with the
-* AC bit and disable traps or not.
-*/
-
-   /* I've only seen MicroSparc's on SparcClassics with this
-* bit set.
-*/
-   set 0x800, %g2
-   lda [%g0] ASI_M_MMUREGS, %g3! peek in the control 
reg
-   and %g2, %g3, %g3
-   subcc   %g3, 0x0, %g0
-   bnz srmmu_not_viking! is in mbus 
mode
-nop
-
-   rd  %psr, %g3   ! DO NOT TOUCH %g3
-   andn%g3, PSR_ET, %g2
-   wr  %g2, 0x0, %psr
-   WRITE_PAUSE
-
-   /* Get context table pointer, then convert to
-* a physical address, which is 36 bits.
-*/
-   set AC_M_CTPR, %g4
-   lda [%g4] ASI_M_MMUREGS, %g4
-   sll %g4, 0x4, %g4   ! We use this below
-   ! DO NOT TOUCH %g4
-
-   /* Set the AC bit in the Viking's MMU control reg. */
-   lda [%g0] ASI_M_MMUREGS, %g5! DO NOT TOUCH %g5
-   set 0x8000, %g6 ! AC bit mask
-   or  %g5, %g6, %g6   ! Or it in...
-   sta %g6, [%g0] ASI_M_MMUREGS! Close your eyes...
-
-   /* Grrr, why does it seem like every other load/store
-* on the sun4m is in some ASI space...
-* Fine with me, let's get the pointer to the level 1
-* page table directory and fetch its entry.
-*/
-   lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
-   srl %o1, 0x4, %o1   ! Clear low 4 bits
-   sll %o1, 0x8, %o1   ! Make physical
-
-   /* Ok, pull in the PTD. */
-   lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB 
pgd
-
-   /* Calculate to KERNBASE entry. */
-   add %o1, KERNBASE >> (PGDIR_SHIFT - 2), %o3
-
-   /* Poke the entry into the calculated address. */
-   sta %o2, [%o3] ASI_M_BYPASS
-
-   /* I don't get it Sun, if you engineered all these
-* boot loaders and the PROM (thank you for the debugging
-* features btw) why did you not have them load kernel
-* images up in high address space, since this is necessary
-* for ABI compliance anyways?  Does this low-mapping provide
-* enhanced interoperability?
-*
-* "The PROM is the computer."
-*/
-
-   /* Ok, restore the MMU control register we saved in %g5 */
-   sta %g5, [%g0] ASI_M_MMUREGS! POW... ouch
-
-   /* Turn traps back on.  We saved it in %g3 earlier. */
-   wr  %g3, 0x0, %psr  ! tick tock, tick tock
-
-   /* Now we burn precious CPU cycles due to bad engineering. */
-   WRITE_PAUSE
-
-   /* Wow, all that just to move a 32-bit value from one
-* place to another...  Jump to high memory.
-*/
-

Re: [PATCH v8 0/7] Add support for XLCDC to sam9x7 SoC family.

2024-02-22 Thread Sam Ravnborg
On Wed, Feb 21, 2024 at 11:05:24AM +0530, Manikandan Muralidharan wrote:
> This patch series aims to add support for XLCDC IP of sam9x7 SoC family
> to the DRM subsystem.XLCDC IP has additional registers and new
> configuration bits compared to the existing register set of HLCDC IP.
> The new compatible string "microchip,sam9x75-xlcdc" is defined for sam9x75
> variant of the sam9x7 SoC family.The is_xlcdc flag under driver data and
> IP specific driver ops helps to differentiate the XLCDC and existing HLCDC
> code within the same driver.
> 
> changes in v8:
> * Re-arrange the patch set to prepare and update the current HLCDC
> code base with the new LCDC IP based driver ops and then add support
> for XLCDC code changes.
> * Fix Cosmetic issues.
> 
> changes in v7:
> * LCDC IP driver ops functions are declared static and its 
> declaration are removed.
> 
> changes in v6:
> * Fixed Cosmetic defects.
> * Added comments for readability.
> 
> changes in v5:
> * return value of regmap_read_poll_timeout is checked in failure
> case.
> * HLCDC and XLCDC specific driver functions are now invoked
> using its IP specific driver ops w/o the need of checking is_xlcdc flag.
> * Removed empty spaces and blank lines.
> 
> changes in v4:
> * fixed kernel warnings reported by kernel test robot.
> 
> changes in v3:
> * Removed de-referencing the value of is_xlcdc flag multiple times in
> a single function.
> * Removed cpu_relax() call when using regmap_read_poll_timeout.
> * Updated xfactor and yfactor equations using shift operators
> * Defined CSC co-efficients in an array for code readability.
> 
> changes in v2:
> * Change the driver compatible name from "microchip,sam9x7-xlcdc" to
> "microchip,sam9x75-xlcdc".
> * Move is_xlcdc flag to driver data.
> * Remove unsed Macro definitions.
> * Add co-developed-bys tags
> * Replace regmap_read() with regmap_read_poll_timeout() call
> * Split code into two helpers for code readablitity.
> ---
> 
> Durai Manickam KR (1):
>   drm: atmel-hlcdc: Define XLCDC specific registers
> 
> Manikandan Muralidharan (6):
>   drm: atmel-hlcdc: add driver ops to differentiate HLCDC and XLCDC IP
>   drm: atmel_hlcdc: Add support for XLCDC using IP specific driver ops
>   drm: atmel-hlcdc: add DPI mode support for XLCDC
>   drm: atmel-hlcdc: add vertical and horizontal scaling support for
> XLCDC
>   drm: atmel-hlcdc: add support for DSI output formats
>   drm: atmel-hlcdc: add LCD controller layer definition for sam9x75

Hi Manikandan

thanks for your paitent follow-up on this patch set.
Everything looks good and all patches are:
Acked-by: Sam Ravnborg 

We are at v8 now and if there are additional comments we can handle them
in-tree.
I have asked Thomas Zimmermann to apply the patches to drm-misc as I
have lost my push infrastructure atm.

Sam


Re: [PATCH 17/27] sparc32: Drop run-time patching of ASI instructions

2024-02-17 Thread Sam Ravnborg
Hi Andreas,

> > diff --git a/arch/sparc/include/asm/winmacro.h 
> > b/arch/sparc/include/asm/winmacro.h
> > index b6e911f5d93c..c496b04cdfaf 100644
> > --- a/arch/sparc/include/asm/winmacro.h
> > +++ b/arch/sparc/include/asm/winmacro.h
> > @@ -108,18 +108,11 @@
> >  661:   rd  %tbr, %idreg;   \
> > srl %idreg, 10, %idreg; \
> > and %idreg, 0xc, %idreg;\
> 
> These three lines, including the label, should also be removed as they
> are not for LEON. Additionally, I think it would be best to split out
> removing the cpuid instruction fixups to one patch and the MMU ASI
> instruction fixups to another patch.

Nice catch!
I will fix this and split up in two patches in v2.
It will take some days before I have v2 ready, and I will base it on top
of your for-next branch in the sparc.git tree.

Sam

> 
> > -   .section.cpuid_patch, "ax"; \
> > -   /* Instruction location. */ \
> > -   .word   661b;   \
> > -   /* SUN4D implementation. */ \
> > -   lda  [%g0] ASI_M_VIKING_TMP1, %idreg;   \
> > -   sll  %idreg, 2, %idreg; \
> > -   nop;\
> > -   /* LEON implementation. */  \
> > +   \
> > rd  %asr17, %idreg; \
> > srl %idreg, 0x1c, %idreg;   \
> > sll %idreg, 0x02, %idreg;   \
> > -   .previous;  \
> > +   \
> > sethi%hi(current_set), %dest_reg;   \
> > or   %dest_reg, %lo(current_set), %dest_reg;\
> > ld   [%idreg + %dest_reg], %dest_reg;
> > diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
> > index 0f2417ee3f95..9cf8f87e8c42 100644
> > --- a/arch/sparc/kernel/entry.S
> > +++ b/arch/sparc/kernel/entry.S
> 
> The hard_smp_processor_id function also needs to be reduced to just the
> LEON code. With the patching removed, SMP otherwise breaks with CPUs
> other than CPU 0 getting stuck.
> 
> Thanks,
> Andreas


Re: [PATCH 00/27] sparc32: sunset sun4m and sun4d

2024-02-04 Thread Sam Ravnborg
Hi Andreas.

Congratulation being the new sparc co-maintainer!

On Tue, Dec 19, 2023 at 11:03:05PM +0100, Sam Ravnborg via B4 Relay wrote:
> This is the second attempt to sunset sun4m and sun4d.
> See [1] for the inital attempt.

I have now verified that the kernel can boot with qemu.
There was a bug in the uart driver that is fixed and upstream, and then
using the instructions you provided I could use buildroot with an
external kernel tree to get a booting kernel.

Assuming you agree with the patchset how do you want me to move forward?
I can rebase on top of the latest -rc and collect acks if that helps.

Arnd promised to pick up the patches until you got a git tree up,
but I do not expect Arnd to pick up anything unless you have acked or
reviewed said patch(es).

If I rebase the patch-set I will likely include a few bug-fix patches that
was prepared in the meantime.
I can also send them as a separate series, no worries.

Sam


Re: [PATCH v3 0/3] Convert Microchip's HLCDC Text based DT bindings to JSON schema

2024-01-22 Thread Sam Ravnborg
Hi Dharma,
On Mon, Jan 22, 2024 at 03:52:17AM +, dharm...@microchip.com wrote:
> On 20/01/24 6:53 pm, Sam Ravnborg wrote:
> > [You don't often get email from s...@ravnborg.org. Learn why this is 
> > important at https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> > content is safe
> > Hi Sam & Rob,
> > Hi Dharma & Rob.
> > 
> >>> To make the DT binding backward compatible you likely need to add a few
> >>> compatible that otherwise would have been left out - but that should do
> >>> the trick.
> >>>
> >>> The current atmel hlcdc driver that is split in three is IMO an
> >>> over-engineering, and the driver could benefit merging it all in one.
> >>> And the binding should not prevent this.
> >>
> >> I agree on all this, but a conversion is not really the time to redesign
> >> things. Trust me, I've wanted to on lots of conversions. It should be
> >> possible to simplify the driver side while keeping the DT as-is. Just
> >> make the display driver bind to the MFD node instead. After that, then
> >> one could look at flattening everything to 1 node.
> > 
> > Understood and thinking a bit about it fully agreed as well.
> > Dharma - please see my comments only as ideas for the future, and
> > ignore them in this fine rewrite you do.
> > 
> >  Sam
> Based on your insights, I'm contemplating the decision to merge Patch 2 
> [PWM binding] with Patch 3[MFD binding]. It seems redundant given that 
> we already have a PWM node example in the MFD binding.
> 
> Instead of introducing a new PWM binding,
>pwm:
>  $ref: /schemas/pwm/atmel,hlcdc-pwm.yaml
> 
> I will update the existing MFD binding as follows:
> 
> properties:
>compatible:
>  const: atmel,hlcdc-pwm
> 
>"#pwm-cells":
>  const: 3
> 
> required:
>- compatible
>- "#pwm-cells"
> 
As already commented, this looks nice.
But as Rob said, this should be a 1:1 conversion from text to yaml,
and then clean-up can come in the second step.

Sam


Re: [PATCH v3 0/3] Convert Microchip's HLCDC Text based DT bindings to JSON schema

2024-01-22 Thread Sam Ravnborg
Hi Dharma
On Mon, Jan 22, 2024 at 03:52:17AM +, dharm...@microchip.com wrote:
> On 20/01/24 6:53 pm, Sam Ravnborg wrote:
> > [You don't often get email from s...@ravnborg.org. Learn why this is 
> > important at https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> > content is safe
> > Hi Sam & Rob,
> > Hi Dharma & Rob.
> > 
> >>> To make the DT binding backward compatible you likely need to add a few
> >>> compatible that otherwise would have been left out - but that should do
> >>> the trick.
> >>>
> >>> The current atmel hlcdc driver that is split in three is IMO an
> >>> over-engineering, and the driver could benefit merging it all in one.
> >>> And the binding should not prevent this.
> >>
> >> I agree on all this, but a conversion is not really the time to redesign
> >> things. Trust me, I've wanted to on lots of conversions. It should be
> >> possible to simplify the driver side while keeping the DT as-is. Just
> >> make the display driver bind to the MFD node instead. After that, then
> >> one could look at flattening everything to 1 node.
> > 
> > Understood and thinking a bit about it fully agreed as well.
> > Dharma - please see my comments only as ideas for the future, and
> > ignore them in this fine rewrite you do.
> > 
> >  Sam
> Based on your insights, I'm contemplating the decision to merge Patch 2 
> [PWM binding] with Patch 3[MFD binding]. It seems redundant given that 
> we already have a PWM node example in the MFD binding.
> 
> Instead of introducing a new PWM binding,
>pwm:
>  $ref: /schemas/pwm/atmel,hlcdc-pwm.yaml
> 
> I will update the existing MFD binding as follows:
> 
> properties:
>compatible:
>  const: atmel,hlcdc-pwm
> 
>"#pwm-cells":
>  const: 3
> 
> required:
>- compatible
>- "#pwm-cells"
> 
Good idea, this looks like a nice simplification.

Sam


Re: [PATCH v3 0/3] Convert Microchip's HLCDC Text based DT bindings to JSON schema

2024-01-20 Thread Sam Ravnborg
Hi Dharma & Rob.

> > To make the DT binding backward compatible you likely need to add a few
> > compatible that otherwise would have been left out - but that should do
> > the trick.
> > 
> > The current atmel hlcdc driver that is split in three is IMO an
> > over-engineering, and the driver could benefit merging it all in one.
> > And the binding should not prevent this.
> 
> I agree on all this, but a conversion is not really the time to redesign 
> things. Trust me, I've wanted to on lots of conversions. It should be 
> possible to simplify the driver side while keeping the DT as-is. Just 
> make the display driver bind to the MFD node instead. After that, then 
> one could look at flattening everything to 1 node.

Understood and thinking a bit about it fully agreed as well.
Dharma - please see my comments only as ideas for the future, and
ignore them in this fine rewrite you do.

Sam


Re: [PATCH v3 0/3] Convert Microchip's HLCDC Text based DT bindings to JSON schema

2024-01-19 Thread Sam Ravnborg
Hi Dharma,

On Fri, Jan 19, 2024 at 08:41:04AM +, dharm...@microchip.com wrote:
> Hi Sam,
> On 19/01/24 1:00 am, Sam Ravnborg wrote:
> > [You don't often get email from s...@ravnborg.org. Learn why this is 
> > important at https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> > content is safe
> > 
> > Hi Dharma et al.
> > 
> > On Thu, Jan 18, 2024 at 02:56:09PM +0530, Dharma Balasubiramani wrote:
> >> Converted the text bindings to YAML and validated them individually using 
> >> following commands
> >>
> >> $ make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/
> >> $ make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/
> >>
> >> changelogs are available in respective patches.
> >>
> >> Dharma Balasubiramani (3):
> >>dt-bindings: display: convert Atmel's HLCDC to DT schema
> >>dt-bindings: atmel,hlcdc: convert pwm bindings to json-schema
> >>dt-bindings: mfd: atmel,hlcdc: Convert to DT schema format
> > 
> > I know this is a bit late to ask - sorry in advance.
> > 
> > The binding describes the single IP block as a multi functional device,
> > but it is a single IP block that includes the display controller and a
> > simple pwm that can be used for contrast or backlight.
> yes.
> > 
> > If we ignore the fact that the current drivers for hlcdc uses an mfd
> > abstraction, is this then the optimal way to describe the HW?
> > 
> > 
> > In one of my stale git tree I converted atmel lcdc to DT, and here
> Are you referring the "bindings/display/atmel,lcdc.txt"?
Correct.

> > I used:
> > 
> > +  "#pwm-cells":
> > +description:
> > +  This PWM chip use the default 3 cells bindings
> > +  defined in ../../pwm/pwm.yaml.
> > +const: 3
> > +
> > +  clocks:
> > +maxItems: 2
> > +
> > +  clock-names:
> > +maxItems: 2
> > +items:
> > +  - const: lcdc_clk
> > +  - const: hclk
> > 
> > This proved to be a simple way to describe the HW.
> > 
> > To make the DT binding backward compatible you likely need to add a few
> > compatible that otherwise would have been left out - but that should do
> > the trick.
> again you mean the compatibles from atmel,lcdc binding?

If the new binding describes the full IP, as I suggest, then I assume
you need to add the compatible "atmel,hlcdc-pwm" to be backward
compatible. Otherwise users assuming the old binding will fail to find
the pwm info. I am not sure how important this is - but at least then
the device trees can be updated out of sync with the current users.

I hope this explains what I tried to say, otherwise do not hesitate to
get back to me.

Sam


Re: [PATCH v3 0/3] Convert Microchip's HLCDC Text based DT bindings to JSON schema

2024-01-18 Thread Sam Ravnborg
Hi Dharma et al.

On Thu, Jan 18, 2024 at 02:56:09PM +0530, Dharma Balasubiramani wrote:
> Converted the text bindings to YAML and validated them individually using 
> following commands
> 
> $ make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/
> $ make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/
> 
> changelogs are available in respective patches.
> 
> Dharma Balasubiramani (3):
>   dt-bindings: display: convert Atmel's HLCDC to DT schema
>   dt-bindings: atmel,hlcdc: convert pwm bindings to json-schema
>   dt-bindings: mfd: atmel,hlcdc: Convert to DT schema format

I know this is a bit late to ask - sorry in advance.

The binding describes the single IP block as a multi functional device,
but it is a single IP block that includes the display controller and a
simple pwm that can be used for contrast or backlight.

If we ignore the fact that the current drivers for hlcdc uses an mfd
abstraction, is this then the optimal way to describe the HW?


In one of my stale git tree I converted atmel lcdc to DT, and here
I used:

+  "#pwm-cells":
+description:
+  This PWM chip use the default 3 cells bindings
+  defined in ../../pwm/pwm.yaml.
+const: 3
+
+  clocks:
+maxItems: 2
+
+  clock-names:
+maxItems: 2
+items:
+  - const: lcdc_clk
+  - const: hclk

This proved to be a simple way to describe the HW.

To make the DT binding backward compatible you likely need to add a few
compatible that otherwise would have been left out - but that should do
the trick.

The current atmel hlcdc driver that is split in three is IMO an
over-engineering, and the driver could benefit merging it all in one.
And the binding should not prevent this.

Sam


Re: [PATCH 27/27] fbdev/p9100: Drop now unused driver p9100

2024-01-02 Thread Sam Ravnborg
Hi Thomas,

On Tue, Jan 02, 2024 at 09:26:27AM +0100, Thomas Zimmermann wrote:
> Hi Sam
> 
> Am 19.12.23 um 23:03 schrieb Sam Ravnborg via B4 Relay:
> > From: Sam Ravnborg 
> > 
> > The p9100 driver is only relevant for the Sparcbook 3 machine,
> > and with sun4m support removed this driver is no longer relevant.
> > 
> > Signed-off-by: Sam Ravnborg 
> > Cc: "David S. Miller" 
> > Cc: Arnd Bergmann 
> > Cc: Andreas Larsson 
> > Cc: Helge Deller 
> 
> Thanks for cleaning up.
> 
> Ack-by: Thomas Zimmermann 
Thanks.
> 
> if the series is accepted.
As you may have seen there is a maintainer vacuum at the moment :-(
That holds up clean-up a bit, and I cannot find the motivation/time
to offer it myself at the moment (no sponsor for this type of work).

Sam


Re: [PATCH 00/27] sparc32: sunset sun4m and sun4d

2023-12-20 Thread Sam Ravnborg
Hi Mark,

On Wed, Dec 20, 2023 at 11:30:27AM +, Mark Cave-Ayland wrote:
> On 20/12/2023 10:47, Arnd Bergmann wrote:
> 
> > On Wed, Dec 20, 2023, at 09:54, John Paul Adrian Glaubitz wrote:
> > > On Wed, 2023-12-20 at 08:36 +, Arnd Bergmann wrote:
> > > > All of these were found through inspection rather than testing,
> > > > so there is a good chance that other fatal kernel bugs prevent
> > > > testing in qemu, at least until the fixes from Andreas' tree
> > > > are included.
> > > 
> > > Andreas has fixes for these issues?
> > 
> > Not sure, all I know is that
> > 
> > - Andreas has some fixes for Leon in his tree
> > - Sam is unable to boot mainline in qemu
> > - There is an unknown set of bugs in sparc32 since it has not
> >been tested for many years without Andreas' patches
> > 
> > it appears that the qemu developers are still testing the sun4m
> > model against old Linux and Solaris installations [1], but
> > failure to run the leon3 model could still be any combination
> > of kernel, qemu or configuration problems.
> > 
> >  Arnd
> > 
> > [1] https://wiki.qemu.org/Documentation/Platforms/SPARC#Compatibility
> 
> Hi all: I'm one of the QEMU sun4m and sun4u maintainers so thought it would
> be worth a few comments here.

I can imagine that the proposal to drop sun4m from the kernel is then
not the best news this December - sorry about that.

> 
> My SPARC work on QEMU is unsponsored, so of course it is reliant upon me
> finding time between work and family to fix various bugs. This means that I
> simply don't have the time to constantly build and test the latest kernels:
> what generally happens is that someone pings me a regression bug report when
> something breaks and provides a test kernel/rootfs for me to look at. In the
> past both Rob Landley and Guenter Roeck have often flagged regressions and
> kindly provided these for me.
> 
> Other than that I just assume that everything is still working against the
> upstream kernel.

It is a fantastic tool that we can build and boot a kernel using qemu
and your work is appreciated - thanks!

> 
> The leon3_generic machine is maintained by different people so I'd suggest
> contacting them: see [1] for their contact details. I see there is an
> avocado boot test for the leon3_generic machine included within the QEMU
> source tree, but it uses a downloadable image of HelenOS rather than Linux.

Thanks for the pointer, I will try to reach out to them when I have
something a bit more solid than "it does not work".

I tried to hack around a little in qemu and I have an idea where things
goes wrong. The leon_generic assumes another address layout than what is
used by the kernel, so the very first jump to a kernel address fails.

Sam


Re: [PATCH 01/27] sparc32: Update defconfig to LEON SMP

2023-12-19 Thread Sam Ravnborg
Hi Arnd,

On Tue, Dec 19, 2023 at 10:23:05PM +, Arnd Bergmann wrote:
> On Tue, Dec 19, 2023, at 22:03, Sam Ravnborg via B4 Relay wrote:
> > From: Sam Ravnborg 
> >
> > This is a copy of the leon_smp defconfig found in
> > gaisler-buildroot-2023.02-1.0.
> >
> > Signed-off-by: Sam Ravnborg 
> > Cc: "David S. Miller" 
> > Cc: Arnd Bergmann 
> > Cc: Andreas Larsson 
> 
> I did not get a cover letter for the series, but I looked at
You are listed as a receiver?!?

It can be found here:
https://lore.kernel.org/sparclinux/20231219-sam-sparc32-sunset-v3-v1-0-64bb44b59...@ravnborg.org/T/#m2fc5b3c23331efd12492a61ba39ac000a563ac52

> all 27 patches and they all look good to me, nice cleanup!
> 
> Acked-by: Arnd Bergmann 
Thanks!

Sam


[PATCH 07/27] sparc32: Drop run-time patching of ipi trap

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

There is no longer any need for the run-time patching of the ipi trap
with the removal of sun4m and sun4d. Remove the patching and drop the
ipi implementation for the two machines.

The patch includes removal of patching from pcic as this was needed to
fix the build. pcic will be removed in a later commit.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/entry.S | 70 ++-
 arch/sparc/kernel/kernel.h|  4 ---
 arch/sparc/kernel/leon_smp.c  |  3 --
 arch/sparc/kernel/pcic.c  | 11 ---
 arch/sparc/kernel/sun4d_smp.c |  3 --
 arch/sparc/kernel/ttable_32.S |  9 +++---
 6 files changed, 7 insertions(+), 93 deletions(-)

diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index c6a5cb949381..7cf148a996b9 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -174,32 +174,6 @@ maybe_smp4m_msg_check_resched:
 maybe_smp4m_msg_out:
RESTORE_ALL
 
-   .align  4
-   .globl  linux_trap_ipi15_sun4m
-linux_trap_ipi15_sun4m:
-   SAVE_ALL
-   sethi   %hi(0x8000), %o2
-   GET_PROCESSOR4M_ID(o0)
-   sethi   %hi(sun4m_irq_percpu), %l5
-   or  %l5, %lo(sun4m_irq_percpu), %o5
-   sll %o0, 2, %o0
-   ld  [%o5 + %o0], %o5
-   ld  [%o5 + 0x00], %o3   ! sun4m_irq_percpu[cpu]->pending
-   andcc   %o3, %o2, %g0
-   be  sun4m_nmi_error ! Must be an NMI async memory error
-st %o2, [%o5 + 0x04]   ! 
sun4m_irq_percpu[cpu]->clear=0x8000
-   WRITE_PAUSE
-   ld  [%o5 + 0x00], %g0   ! sun4m_irq_percpu[cpu]->pending
-   WRITE_PAUSE
-   or  %l0, PSR_PIL, %l4
-   wr  %l4, 0x0, %psr
-   WRITE_PAUSE
-   wr  %l4, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4m_cross_call_irq
-nop
-   b   ret_trap_lockless_ipi
-clr%l6
 
.globl  smp4d_ticker
/* SMP per-cpu ticker interrupts are handled specially. */
@@ -220,44 +194,6 @@ smp4d_ticker:
WRITE_PAUSE
RESTORE_ALL
 
-   .align  4
-   .globl  linux_trap_ipi15_sun4d
-linux_trap_ipi15_sun4d:
-   SAVE_ALL
-   sethi   %hi(CC_BASE), %o4
-   sethi   %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
-   or  %o4, (CC_EREG - CC_BASE), %o0
-   ldda[%o0] ASI_M_MXCC, %o0
-   andcc   %o0, %o2, %g0
-   bne 1f
-sethi  %hi(BB_STAT2), %o2
-   lduba   [%o2] ASI_M_CTL, %o2
-   andcc   %o2, BB_STAT2_MASK, %g0
-   bne 2f
-or %o4, (CC_ICLR - CC_BASE), %o0
-   sethi   %hi(1 << 15), %o1
-   stha%o1, [%o0] ASI_M_MXCC   /* Clear PIL 15 in MXCC's ICLR */
-   or  %l0, PSR_PIL, %l4
-   wr  %l4, 0x0, %psr
-   WRITE_PAUSE
-   wr  %l4, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4d_cross_call_irq
-nop
-   b   ret_trap_lockless_ipi
-clr%l6
-
-1: /* MXCC error */
-2: /* BB error */
-   /* Disable PIL 15 */
-   set CC_IMSK, %l4
-   lduha   [%l4] ASI_M_MXCC, %l5
-   sethi   %hi(1 << 15), %l7
-   or  %l5, %l7, %l5
-   stha%l5, [%l4] ASI_M_MXCC
-   /* FIXME */
-1: b,a 1b
-
.globl  smpleon_ipi
.extern leon_ipi_interrupt
/* SMP per-cpu IPI interrupts are handled specially. */
@@ -618,11 +554,11 @@ sun4m_nmi_error:
 
 #ifndef CONFIG_SMP
.align  4
-   .globl  linux_trap_ipi15_sun4m
-linux_trap_ipi15_sun4m:
+   .globl  linux_trap_ipi15_leon
+linux_trap_ipi15_leon:
SAVE_ALL
 
-   ba  sun4m_nmi_error
+   ba  sun4m_nmi_error
 nop
 #endif /* CONFIG_SMP */
 
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index c8ba3bc7e137..1d3980ac0658 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -134,10 +134,6 @@ void leonsmp_ipi_interrupt(void);
 void leon_cross_call_irq(void);
 
 /* head_32.S */
-extern unsigned int t_nmi[];
-extern unsigned int linux_trap_ipi15_sun4d[];
-extern unsigned int linux_trap_ipi15_sun4m[];
-
 extern struct tt_entry trapbase;
 extern struct tt_entry trapbase_cpu1;
 extern struct tt_entry trapbase_cpu2;
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 991e9ad3d3e8..42820c7422dd 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -463,8 +463,5 @@ static const struct sparc32_ipi_ops leon_ipi_ops = {
 
 void __init leon_init_smp(void)
 {
-   /* Patch ipi15 trap table */
-   t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_leon - linux_trap_ipi15_sun4m);
-
sparc32_ipi_ops = _ipi_ops;
 }
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 25fe0a061732..d952bcbbc395 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -354,17 +354,6 @@ int __init pcic_probe(void)
prom_

[PATCH 12/27] sparc32: Drop mbus support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Only used by older SPARC HW, not used by LEON.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/elf_32.h |  2 -
 arch/sparc/include/asm/mbus.h   | 97 -
 arch/sparc/kernel/cpu.c |  1 -
 arch/sparc/kernel/setup_32.c|  1 -
 arch/sparc/mm/iommu.c   | 18 ++--
 arch/sparc/mm/srmmu.c   | 48 
 6 files changed, 3 insertions(+), 164 deletions(-)

diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
index 37a6016c9ccd..b2cca9be55c2 100644
--- a/arch/sparc/include/asm/elf_32.h
+++ b/arch/sparc/include/asm/elf_32.h
@@ -91,8 +91,6 @@ typedef struct {
unsigned intpr_q[64];
 } elf_fpregset_t;
 
-#include 
-
 /*
  * This is used to ensure we don't load something for the wrong architecture.
  */
diff --git a/arch/sparc/include/asm/mbus.h b/arch/sparc/include/asm/mbus.h
deleted file mode 100644
index 8b6dbe701b9b..
--- a/arch/sparc/include/asm/mbus.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * mbus.h:  Various defines for MBUS modules.
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#ifndef _SPARC_MBUS_H
-#define _SPARC_MBUS_H
-
-#include /* HyperSparc stuff */
-#include   /* Ugh, bug city... */
-
-enum mbus_module {
-   HyperSparc= 0,
-   Swift_ok  = 4,
-   Swift_bad_c   = 5,
-   Swift_lots_o_bugs = 6,
-   Tsunami   = 7,
-   Viking_12 = 8,
-   Viking_2x = 9,
-   Viking_30 = 10,
-   Viking_35 = 11,
-   Viking_new= 12,
-   TurboSparc= 13,
-   SRMMU_INVAL_MOD   = 14,
-};
-
-extern enum mbus_module srmmu_modtype;
-extern unsigned int viking_rev, swift_rev, cypress_rev;
-
-/* HW Mbus module bugs we have to deal with */
-#define HWBUG_COPYBACK_BROKEN0x0001
-#define HWBUG_ASIFLUSH_BROKEN0x0002
-#define HWBUG_VACFLUSH_BITROT0x0004
-#define HWBUG_KERN_ACCBROKEN 0x0008
-#define HWBUG_KERN_CBITBROKEN0x0010
-#define HWBUG_MODIFIED_BITROT0x0020
-#define HWBUG_PC_BADFAULT_ADDR   0x0040
-#define HWBUG_SUPERSCALAR_BAD0x0080
-#define HWBUG_PACINIT_BITROT 0x0100
-
-/* First the module type values. To find out which you have, just load
- * the mmu control register from ASI_M_MMUREG alternate address space and
- * shift the value right 28 bits.
- */
-/* IMPL field means the company which produced the chip. */
-#define MBUS_VIKING0x4   /* bleech, Texas Instruments Module */
-#define MBUS_LSI   0x3   /* LSI Logics */
-#define MBUS_ROSS  0x1   /* Ross is nice */
-#define MBUS_FMI   0x0   /* Fujitsu Microelectronics/Swift */
-
-/* Ross Module versions */
-#define ROSS_604_REV_CDE0x0   /* revisions c, d, and e */
-#define ROSS_604_REV_F  0x1   /* revision f */
-#define ROSS_6050xf   /* revision a, a.1, and a.2 */
-#define ROSS_605_REV_B  0xe   /* revision b */
-
-/* TI Viking Module versions */
-#define VIKING_REV_12   0x1   /* Version 1.2 or SPARCclassic's CPU */
-#define VIKING_REV_20x2   /* Version 2.1, 2.2, 2.3, and 2.4 */
-#define VIKING_REV_30   0x3   /* Version 3.0 */
-#define VIKING_REV_35   0x4   /* Version 3.5 */
-
-/* LSI Logics. */
-#define LSI_L64815 0x0
-
-/* Fujitsu */
-#define FMI_AURORA 0x4   /* MB8690x, a Swift module... */
-#define FMI_TURBO  0x5   /* MB86907, a TurboSparc module... */
-
-/* For multiprocessor support we need to be able to obtain the CPU id and
- * the MBUS Module id.
- */
-
-/* The CPU ID is encoded in the trap base register, 20 bits to the left of
- * bit zero, with 2 bits being significant.
- */
-#define TBR_ID_SHIFT20
-
-static inline int get_cpuid(void)
-{
-   register int retval;
-   __asm__ __volatile__("rd %%tbr, %0\n\t"
-"srl %0, %1, %0\n\t" :
-"=r" (retval) :
-"i" (TBR_ID_SHIFT));
-   return (retval & 3);
-}
-
-static inline int get_modid(void)
-{
-   return (get_cpuid() | 0x8);
-}
-
-   
-#endif /* !(_SPARC_MBUS_H) */
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
index 79cd6ccfeac0..cca7de051593 100644
--- a/arch/sparc/kernel/cpu.c
+++ b/arch/sparc/kernel/cpu.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "kernel.h"
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index e3b72a7b46d3..5a497140c52a 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -41,7 +41,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/

[PATCH 20/27] sparc32: Drop unused prom ranges support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop support for prom ranges - not used anymore.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/oplib_32.h |  11 
 arch/sparc/prom/Makefile  |   1 -
 arch/sparc/prom/init_32.c |   2 -
 arch/sparc/prom/ranges.c  | 114 --
 4 files changed, 128 deletions(-)

diff --git a/arch/sparc/include/asm/oplib_32.h 
b/arch/sparc/include/asm/oplib_32.h
index d1cf3a27a40d..4ef7f05978d3 100644
--- a/arch/sparc/include/asm/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
@@ -163,17 +163,6 @@ int prom_setprop(phandle node, const char *prop_name, char 
*prop_value,
 
 phandle prom_inst2pkg(int);
 
-/* Dorking with Bus ranges... */
-
-/* Apply promlib probes OBIO ranges to registers. */
-void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
-
-/* Apply ranges of any prom node (and optionally parent node as well) to 
registers. */
-void prom_apply_generic_ranges(phandle node, phandle parent,
-  struct linux_prom_registers *sbusregs, int 
nregs);
-
-void prom_ranges_init(void);
-
 /* CPU probing helpers.  */
 int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
 int cpu_find_by_mid(int mid, phandle *prom_node);
diff --git a/arch/sparc/prom/Makefile b/arch/sparc/prom/Makefile
index 397b79af77f7..6d94d8b28bcf 100644
--- a/arch/sparc/prom/Makefile
+++ b/arch/sparc/prom/Makefile
@@ -10,7 +10,6 @@ lib-y += init_$(BITS).o
 lib-$(CONFIG_SPARC32) += memory.o
 lib-y += misc_$(BITS).o
 lib-$(CONFIG_SPARC32) += mp.o
-lib-$(CONFIG_SPARC32) += ranges.o
 lib-y += console_$(BITS).o
 lib-y += printf.o
 lib-y += tree_$(BITS).o
diff --git a/arch/sparc/prom/init_32.c b/arch/sparc/prom/init_32.c
index d20470166cb1..1681f1f980d4 100644
--- a/arch/sparc/prom/init_32.c
+++ b/arch/sparc/prom/init_32.c
@@ -67,8 +67,6 @@ void __init prom_init(struct linux_romvec *rp)
 
prom_meminit();
 
-   prom_ranges_init();
-
printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
   romvec->pv_romvers, prom_rev);
 
diff --git a/arch/sparc/prom/ranges.c b/arch/sparc/prom/ranges.c
deleted file mode 100644
index 20cb828bc5f4..
--- a/arch/sparc/prom/ranges.c
+++ /dev/null
@@ -1,114 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * ranges.c: Handle ranges in newer proms for obio/sbus.
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- * Copyright (C) 1997 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
- */
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-static struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX];
-static int num_obio_ranges;
-
-/* Adjust register values based upon the ranges parameters. */
-static void prom_adjust_regs(struct linux_prom_registers *regp, int nregs,
-struct linux_prom_ranges *rangep, int nranges)
-{
-   int regc, rngc;
-
-   for (regc = 0; regc < nregs; regc++) {
-   for (rngc = 0; rngc < nranges; rngc++)
-   if (regp[regc].which_io == rangep[rngc].ot_child_space)
-   break; /* Fount it */
-   if (rngc == nranges) /* oops */
-   prom_printf("adjust_regs: Could not find range with 
matching bus type...\n");
-   regp[regc].which_io = rangep[rngc].ot_parent_space;
-   regp[regc].phys_addr -= rangep[rngc].ot_child_base;
-   regp[regc].phys_addr += rangep[rngc].ot_parent_base;
-   }
-}
-
-static void prom_adjust_ranges(struct linux_prom_ranges *ranges1, int nranges1,
-  struct linux_prom_ranges *ranges2, int nranges2)
-{
-   int rng1c, rng2c;
-
-   for (rng1c = 0; rng1c < nranges1; rng1c++) {
-   for (rng2c = 0; rng2c < nranges2; rng2c++)
-   if (ranges1[rng1c].ot_parent_space == 
ranges2[rng2c].ot_child_space &&
-  ranges1[rng1c].ot_parent_base >= 
ranges2[rng2c].ot_child_base &&
-  ranges2[rng2c].ot_child_base + 
ranges2[rng2c].or_size - ranges1[rng1c].ot_parent_base > 0U)
-   break;
-   if (rng2c == nranges2) /* oops */
-   prom_printf("adjust_ranges: Could not find matching bus 
type...\n");
-   else if (ranges1[rng1c].ot_parent_base + ranges1[rng1c].or_size 
> ranges2[rng2c].ot_child_base + ranges2[rng2c].or_size)
-   ranges1[rng1c].or_size = ranges2[rng2c].ot_child_base + 
ranges2[rng2c].or_size - ranges1[rng1c].ot_parent_base;
-   ranges1[rng1c].ot_parent_space = ranges2[rng2c].ot_parent_space;
-   ranges1[rng1c].ot_parent_base += ranges2[rng2c].ot_parent_base;
-   }
-}
-

[PATCH 14/27] sparc32: Drop unused mmu models

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop mmu models not used by LEON, including their header files.
This includes removal of unused includes in various files to fix the
build.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/mxcc.h   | 138 ---
 arch/sparc/include/asm/ross.h   | 192 -
 arch/sparc/include/asm/swift.h  | 107 -
 arch/sparc/include/asm/tsunami.h|  65 ---
 arch/sparc/include/asm/turbosparc.h | 126 --
 arch/sparc/include/asm/viking.h | 255 
 arch/sparc/kernel/entry.S   |   1 -
 arch/sparc/mm/Makefile  |   1 -
 arch/sparc/mm/hypersparc.S  | 414 ---
 arch/sparc/mm/io-unit.c |   1 -
 arch/sparc/mm/iommu.c   |  31 +-
 arch/sparc/mm/mm_32.h   |   1 -
 arch/sparc/mm/srmmu.c   | 776 +---
 arch/sparc/mm/swift.S   | 256 
 arch/sparc/mm/tsunami.S | 132 --
 arch/sparc/mm/viking.S  | 284 -
 16 files changed, 21 insertions(+), 2759 deletions(-)

diff --git a/arch/sparc/include/asm/mxcc.h b/arch/sparc/include/asm/mxcc.h
deleted file mode 100644
index 3a2561bea4dd..
--- a/arch/sparc/include/asm/mxcc.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * mxcc.h:  Definitions of the Viking MXCC registers
- *
- * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#ifndef _SPARC_MXCC_H
-#define _SPARC_MXCC_H
-
-/* These registers are accessed through ASI 0x2. */
-#define MXCC_DATSTREAM   0x1C0  /* Data stream register */
-#define MXCC_SRCSTREAM   0x1C00100  /* Source stream register */
-#define MXCC_DESSTREAM   0x1C00200  /* Destination stream register */
-#define MXCC_RMCOUNT 0x1C00300  /* Count of references and misses */
-#define MXCC_STEST   0x1C00804  /* Internal self-test */
-#define MXCC_CREG0x1C00A04  /* Control register */
-#define MXCC_SREG0x1C00B00  /* Status register */
-#define MXCC_RREG0x1C00C04  /* Reset register */
-#define MXCC_EREG0x1C00E00  /* Error code register */
-#define MXCC_PREG0x1C00F04  /* Address port register */
-
-/* Some MXCC constants. */
-#define MXCC_STREAM_SIZE 0x20   /* Size in bytes of one stream r/w */
-
-/* The MXCC Control Register:
- *
- * --
- * |   | RRC | RSV |PRE|MCE|PARE|ECE|RSV|
- * --
- *  31  1098-6   5   43   2  1-0
- *
- * RRC: Controls what you read from MXCC_RMCOUNT reg.
- *  0=Misses 1=References
- * PRE: Prefetch enable
- * MCE: Multiple Command Enable
- * PARE: Parity enable
- * ECE: External cache enable
- */
-
-#define MXCC_CTL_RRC   0x0200
-#define MXCC_CTL_PRE   0x0020
-#define MXCC_CTL_MCE   0x0010
-#define MXCC_CTL_PARE  0x0008
-#define MXCC_CTL_ECE   0x0004
-
-/* The MXCC Error Register:
- *
- * 
- * |ME| RSV|CE|PEW|PEE|ASE|EIV| MOPC|ECODE|PRIV|RSV|HPADDR|
- * 
- *  31   30 29  28  27  26  25 24-15  14-7   6  5-3   2-0
- *
- * ME: Multiple Errors have occurred
- * CE: Cache consistency Error
- * PEW: Parity Error during a Write operation
- * PEE: Parity Error involving the External cache
- * ASE: ASynchronous Error
- * EIV: This register is toast
- * MOPC: MXCC Operation Code for instance causing error
- * ECODE: The Error CODE
- * PRIV: A privileged mode error? 0=no 1=yes
- * HPADDR: High PhysicalADDRess bits (35-32)
- */
-
-#define MXCC_ERR_ME 0x8000
-#define MXCC_ERR_CE 0x2000
-#define MXCC_ERR_PEW0x1000
-#define MXCC_ERR_PEE0x0800
-#define MXCC_ERR_ASE0x0400
-#define MXCC_ERR_EIV0x0200
-#define MXCC_ERR_MOPC   0x01FF8000
-#define MXCC_ERR_ECODE  0x7F80
-#define MXCC_ERR_PRIV   0x0040
-#define MXCC_ERR_HPADDR 0x000f
-
-/* The MXCC Port register:
- *
- * -
- * || MID ||
- * -
- *  3121 20-18 17 0
- *
- * MID: The moduleID of the cpu your read this from.
- */
-
-#ifndef __ASSEMBLY__
-
-static inline void mxcc_set_stream_src(unsigned long *paddr)
-{
-   unsigned long data0 = paddr[0];
-   unsigned long data1 = paddr[1];
-
-   __asm__ __volatile__ ("or %%g0, %0, %%g2\n\t"
- "or %%g0, %1, %%g3\n\t"
- "stda %%g2, [%2] %3\n\t" : :
- "r" (data0), "r" (data1),
-   

[PATCH 13/27] sparc32: Drop unused function __get_{phys,iospace}

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Not used and references stuff that will be dropped later.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/pgtable_32.h | 24 
 arch/sparc/include/asm/pgtsrmmu.h   | 11 ---
 2 files changed, 35 deletions(-)

diff --git a/arch/sparc/include/asm/pgtable_32.h 
b/arch/sparc/include/asm/pgtable_32.h
index 9e85d57ac3f2..92b063531d5c 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -368,30 +368,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
return __pte(pte_val(pte) & ~SRMMU_SWP_EXCLUSIVE);
 }
 
-static inline unsigned long
-__get_phys (unsigned long addr)
-{
-   switch (sparc_cpu_model){
-   case sun4m:
-   case sun4d:
-   return ((srmmu_get_pte (addr) & 0xff00) << 4);
-   default:
-   return 0;
-   }
-}
-
-static inline int
-__get_iospace (unsigned long addr)
-{
-   switch (sparc_cpu_model){
-   case sun4m:
-   case sun4d:
-   return (srmmu_get_pte (addr) >> 28);
-   default:
-   return -1;
-   }
-}
-
 /*
  * For sparc32&64, the pfn in io_remap_pfn_range() carries  in
  * its high 4 bits.  These macros/functions put it there or get it from there.
diff --git a/arch/sparc/include/asm/pgtsrmmu.h 
b/arch/sparc/include/asm/pgtsrmmu.h
index 18e68d43f036..7cb5cbc83211 100644
--- a/arch/sparc/include/asm/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
@@ -125,17 +125,6 @@ static inline void srmmu_flush_whole_tlb(void)
 
 }
 
-static inline int
-srmmu_get_pte (unsigned long addr)
-{
-   register unsigned long entry;
-
-   __asm__ __volatile__("\n\tlda [%1] %2,%0\n\t" :
-   "=r" (entry):
-   "r" ((addr & 0xf000) | 0x400), "i" 
(ASI_M_FLUSH_PROBE));
-   return entry;
-}
-
 #endif /* !(__ASSEMBLY__) */
 
 #endif /* !(_SPARC_PGTSRMMU_H) */

-- 
2.34.1



[PATCH 06/27] sparc32: Drop auxio support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

auxio is not supported by LEON - so drop it.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/auxio_32.h |  73 +---
 arch/sparc/kernel/Makefile|   2 +-
 arch/sparc/kernel/auxio_32.c  | 139 --
 arch/sparc/kernel/devices.c   |   3 -
 arch/sparc/kernel/kernel.h|   4 --
 arch/sparc/kernel/process_32.c|  10 ---
 arch/sparc/prom/misc_32.c |   2 -
 7 files changed, 3 insertions(+), 230 deletions(-)

diff --git a/arch/sparc/include/asm/auxio_32.h 
b/arch/sparc/include/asm/auxio_32.h
index 852457c7a265..e2335ddd359d 100644
--- a/arch/sparc/include/asm/auxio_32.h
+++ b/arch/sparc/include/asm/auxio_32.h
@@ -1,43 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * auxio.h:  Definitions and code for the Auxiliary I/O register.
+ * Dummy definitions for the Auxiliary I/O register.
  *
  * Copyright (C) 1995 David S. Miller (da...@caip.rutgers.edu)
  */
 #ifndef _SPARC_AUXIO_H
 #define _SPARC_AUXIO_H
 
-#include 
-
-/* This register is an unsigned char in IO space.  It does two things.
- * First, it is used to control the front panel LED light on machines
- * that have it (good for testing entry points to trap handlers and irq's)
- * Secondly, it controls various floppy drive parameters.
- */
-#define AUXIO_ORMEIN  0xf0/* All writes must set these bits. */
-#define AUXIO_ORMEIN4M0xc0/* sun4m - All writes must set these bits. */
-#define AUXIO_FLPY_DENS   0x20/* Floppy density, high if set. Read only. */
-#define AUXIO_FLPY_DCHG   0x10/* A disk change occurred.  Read only. */
-#define AUXIO_EDGE_ON 0x10/* sun4m - On means Jumper block is in. */
-#define AUXIO_FLPY_DSEL   0x08/* Drive select/start-motor. Write only. */
-#define AUXIO_LINK_TEST   0x08/* sun4m - On means TPE Carrier detect. */
-
-/* Set the following to one, then zero, after doing a pseudo DMA transfer. */
-#define AUXIO_FLPY_TCNT   0x04/* Floppy terminal count. Write only. */
-
-/* Set the following to zero to eject the floppy. */
-#define AUXIO_FLPY_EJCT   0x02/* Eject floppy disk.  Write only. */
-#define AUXIO_LED 0x01/* On if set, off if unset. Read/Write */
-
-#ifndef __ASSEMBLY__
-
-/*
- * NOTE: these routines are implementation dependent--
- * understand the hardware you are querying!
- */
-void set_auxio(unsigned char bits_on, unsigned char bits_off);
-unsigned char get_auxio(void); /* .../asm/floppy.h */
-
 /*
  * The following routines are provided for driver-compatibility
  * with sparc64 (primarily sunlance.c)
@@ -46,44 +15,6 @@ unsigned char get_auxio(void); /* .../asm/floppy.h */
 #define AUXIO_LTE_ON1
 #define AUXIO_LTE_OFF   0
 
-/* auxio_set_lte - Set Link Test Enable (TPE Link Detect)
- *
- * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
- */
-#define auxio_set_lte(on) \
-do { \
-   if(on) { \
-   set_auxio(AUXIO_LINK_TEST, 0); \
-   } else { \
-   set_auxio(0, AUXIO_LINK_TEST); \
-   } \
-} while (0)
-
-#define AUXIO_LED_ON1
-#define AUXIO_LED_OFF   0
-
-/* auxio_set_led - Set system front panel LED
- *
- * on - AUXIO_LED_ON or AUXIO_LED_OFF
- */
-#define auxio_set_led(on) \
-do { \
-   if(on) { \
-   set_auxio(AUXIO_LED, 0); \
-   } else { \
-   set_auxio(0, AUXIO_LED); \
-   } \
-} while (0)
-
-#endif /* !(__ASSEMBLY__) */
-
-
-/* AUXIO2 (Power Off Control) */
-extern volatile u8 __iomem *auxio_power_register;
-
-#defineAUXIO_POWER_DETECT_FAILURE  32
-#defineAUXIO_POWER_CLEAR_FAILURE   2
-#defineAUXIO_POWER_OFF 1
-
+#define auxio_set_lte(on)
 
 #endif /* !(_SPARC_AUXIO_H) */
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index ab47823f8b4e..577cb57c588a 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -83,7 +83,7 @@ obj-$(CONFIG_SMP) += trampoline_$(BITS).o 
smp_$(BITS).o
 obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
-obj-y += auxio_$(BITS).o
+obj-$(CONFIG_SPARC64) += auxio_64.o
 
 obj-y += termios.o
 
diff --git a/arch/sparc/kernel/auxio_32.c b/arch/sparc/kernel/auxio_32.c
deleted file mode 100644
index 989860e890c4..
--- a/arch/sparc/kernel/auxio_32.c
+++ /dev/null
@@ -1,139 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* auxio.c: Probing for the Sparc AUXIO register at boot time.
- *
- * Copyright (C) 1996 David S. Miller (da...@caip.rutgers.edu)
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include /* memset(), Linux has no bzero() */
-#include 
-
-#include "kernel.h"
-
-/* Probe and map in the Auxiliary I/O register */
-
-/* auxio_register is not static because it is referenced 
- * in entry.S::floppy_tdon

[PATCH 24/27] sparc32: Drop config SPARC_LEON

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The only support sparc32 CPU is LEON, so there is no need for a
config option to select it.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig   | 27 +--
 arch/sparc/configs/sparc32_defconfig |  1 -
 drivers/usb/host/Kconfig |  2 +-
 drivers/usb/host/ehci-hcd.c  |  4 ++--
 drivers/usb/host/uhci-hcd.c  |  2 +-
 5 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 7ae304bab2d8..0fc52c3c7487 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -9,6 +9,10 @@ config 64BIT
 
  Say yes to build a 64-bit kernel - formerly known as sparc64
  Say no to build a 32-bit kernel - formerly known as sparc
+ The 32-bit kernel target the synthesizable LEON SPARC processor.
+ LEON is a part of the GRLIB collection of IP cores that are
+ distributed under GPL. GRLIB can be downloaded from www.gaisler.com.
+ You can download a sparc-linux cross-compilation toolchain at 
www.gaisler.com.
 
 config SPARC
bool
@@ -60,6 +64,10 @@ config SPARC32
select HAVE_UID16
select LOCK_MM_AND_FIND_VMA
select OLD_SIGACTION
+   select USB_EHCI_BIG_ENDIAN_MMIO
+   select USB_EHCI_BIG_ENDIAN_DESC
+   select USB_UHCI_BIG_ENDIAN_MMIO
+   select USB_UHCI_BIG_ENDIAN_DESC
select ZONE_DMA
 
 config SPARC64
@@ -348,22 +356,6 @@ config SERIAL_CONSOLE
 
  If unsure, say N.
 
-config SPARC_LEON
-   bool "Sparc Leon processor family"
-   depends on SPARC32
-   select USB_EHCI_BIG_ENDIAN_MMIO
-   select USB_EHCI_BIG_ENDIAN_DESC
-   select USB_UHCI_BIG_ENDIAN_MMIO
-   select USB_UHCI_BIG_ENDIAN_DESC
-   help
- If you say Y here if you are running on a SPARC-LEON processor.
- The LEON processor is a synthesizable VHDL model of the
- SPARC-v8 standard. LEON is  part of the GRLIB collection of
- IP cores that are distributed under GPL. GRLIB can be downloaded
- from www.gaisler.com. You can download a sparc-linux cross-compilation
- toolchain at www.gaisler.com.
-
-if SPARC_LEON
 menu "U-Boot options"
 
 config UBOOT_LOAD_ADDR
@@ -394,7 +386,6 @@ config UBOOT_ENTRY_ADDR
 Kernel.
 
 endmenu
-endif
 
 endmenu
 
@@ -416,7 +407,7 @@ config SUN_LDOMS
 
 config LEON_PCI
bool
-   depends on PCI && SPARC_LEON
+   depends on PCI && SPARC32
default y
 
 config SPARC_GRPCI1
diff --git a/arch/sparc/configs/sparc32_defconfig 
b/arch/sparc/configs/sparc32_defconfig
index 71273fc578bf..dfd326f20876 100644
--- a/arch/sparc/configs/sparc32_defconfig
+++ b/arch/sparc/configs/sparc32_defconfig
@@ -10,7 +10,6 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_RD_ZSTD is not set
 CONFIG_SMP=y
 CONFIG_HZ_100=y
-CONFIG_SPARC_LEON=y
 CONFIG_SUN_OPENPROMFS=y
 CONFIG_SUN_OPENPROMIO=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 4448d0ab06f0..c5f94c70482f 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -595,7 +595,7 @@ config USB_UHCI_HCD
 
 config USB_UHCI_SUPPORT_NON_PCI_HC
bool
-   default y if (SPARC_LEON || USB_UHCI_PLATFORM)
+   default y if (SPARC32 || USB_UHCI_PLATFORM)
 
 config USB_UHCI_PLATFORM
bool
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 802bfafb1012..5011bc8348bb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1329,7 +1329,7 @@ MODULE_LICENSE ("GPL");
 #include "ehci-xilinx-of.c"
 #endif
 
-#ifdef CONFIG_SPARC_LEON
+#ifdef CONFIG_SPARC32
 #include "ehci-grlib.c"
 #endif
 
@@ -1343,7 +1343,7 @@ static struct platform_driver * const platform_drivers[] 
= {
 #ifdef CONFIG_XPS_USB_HCD_XILINX
_hcd_xilinx_of_driver,
 #endif
-#ifdef CONFIG_SPARC_LEON
+#ifdef CONFIG_SPARC32
_grlib_driver,
 #endif
 };
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index fd2408b553cf..7cb820963988 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -846,7 +846,7 @@ static const char hcd_name[] = "uhci_hcd";
 #definePCI_DRIVER  uhci_pci_driver
 #endif
 
-#ifdef CONFIG_SPARC_LEON
+#ifdef CONFIG_SPARC32
 #include "uhci-grlib.c"
 #define PLATFORM_DRIVERuhci_grlib_driver
 #endif

-- 
2.34.1



[PATCH 22/27] sparc32: Drop sun4m irq support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop all code uses to support sun4m irqs.
Update entry.S to call the leon_nmi function.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/Makefile  |   1 -
 arch/sparc/kernel/entry.S   |  29 ++---
 arch/sparc/kernel/irq.h |  47 +---
 arch/sparc/kernel/irq_32.c  |   6 +-
 arch/sparc/kernel/kernel.h  |   4 -
 arch/sparc/kernel/leon_kernel.c |  10 +-
 arch/sparc/kernel/sun4m_irq.c   | 238 
 7 files changed, 23 insertions(+), 312 deletions(-)

diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 09577e39037c..1961d165b279 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -29,7 +29,6 @@ obj-y   += traps_$(BITS).o
 
 # IRQ
 obj-y   += irq_$(BITS).o
-obj-$(CONFIG_SPARC32)   += sun4m_irq.o
 
 obj-y   += process_$(BITS).o
 obj-y   += process.o
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index eecbe0be7bf6..fb6095aab9c2 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -427,36 +427,21 @@ setcc_trap_handler:
jmp %l2 ! advance over trap instruction
rett%l2 + 0x4   ! like this...
 
-sun4m_nmi_error:
+nmi_error:
/* NMI async memory error handling. */
-   sethi   %hi(0x8000), %l4
-   sethi   %hi(sun4m_irq_global), %o5
-   ld  [%o5 + %lo(sun4m_irq_global)], %l5
-   st  %l4, [%l5 + 0x0c]   ! sun4m_irq_global->mask_set=0x8000
-   WRITE_PAUSE
-   ld  [%l5 + 0x00], %g0   ! sun4m_irq_global->pending
-   WRITE_PAUSE
+#ifndef CONFIG_SMP
+   .align  4
+   .globl  linux_trap_ipi15_leon
+linux_trap_ipi15_leon:
+   SAVE_ALL
or  %l0, PSR_PIL, %l4
wr  %l4, 0x0, %psr
WRITE_PAUSE
wr  %l4, PSR_ET, %psr
WRITE_PAUSE
-   callsun4m_nmi
+   callleon_nmi
 nop
-   st  %l4, [%l5 + 0x08]   ! 
sun4m_irq_global->mask_clear=0x8000
-   WRITE_PAUSE
-   ld  [%l5 + 0x00], %g0   ! sun4m_irq_global->pending
-   WRITE_PAUSE
RESTORE_ALL
-
-#ifndef CONFIG_SMP
-   .align  4
-   .globl  linux_trap_ipi15_leon
-linux_trap_ipi15_leon:
-   SAVE_ALL
-
-   ba  sun4m_nmi_error
-nop
 #endif /* CONFIG_SMP */
 
.align  4
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
index 8a0b314c8299..9d15dbb9fe6f 100644
--- a/arch/sparc/kernel/irq.h
+++ b/arch/sparc/kernel/irq.h
@@ -10,39 +10,14 @@ struct irq_bucket {
 unsigned int pil;
 };
 
-#define SUN4M_HARD_INT(x)   (0x1 << (x))
-#define SUN4M_SOFT_INT(x)   (0x1 << (x))
-
-#define SUN4D_MAX_BOARD 10
-#define SUN4D_MAX_IRQ ((SUN4D_MAX_BOARD + 2) << 5)
+#define MAX_BOARD 10
+#define MAX_IRQ ((MAX_BOARD + 2) << 5)
 
 /* Map between the irq identifier used in hw to the
  * irq_bucket. The map is sufficient large to hold
  * the sun4d hw identifiers.
  */
-extern struct irq_bucket *irq_map[SUN4D_MAX_IRQ];
-
-
-/* sun4m specific type definitions */
-
-/* This maps direct to CPU specific interrupt registers */
-struct sun4m_irq_percpu {
-   u32 pending;
-   u32 clear;
-   u32 set;
-};
-
-/* This maps direct to global interrupt registers */
-struct sun4m_irq_global {
-   u32 pending;
-   u32 mask;
-   u32 mask_clear;
-   u32 mask_set;
-   u32 interrupt_target;
-};
-
-extern struct sun4m_irq_percpu __iomem *sun4m_irq_percpu[SUN4M_NCPUS];
-extern struct sun4m_irq_global __iomem *sun4m_irq_global;
+extern struct irq_bucket *irq_map[MAX_IRQ];
 
 unsigned int irq_alloc(unsigned int real_irq, unsigned int pil);
 void irq_link(unsigned int irq);
@@ -51,22 +26,8 @@ void handler_irq(unsigned int pil, struct pt_regs *regs);
 
 unsigned long leon_get_irqmask(unsigned int irq);
 
-/* sun4m_irq.c */
-void sun4m_nmi(struct pt_regs *regs);
-
-/* sun4d_irq.c */
-void sun4d_handler_irq(unsigned int pil, struct pt_regs *regs);
-
 /* leon_kernel.c */
 void leon_clear_clock_irq(void);
 void leon_load_profile_irq(int cpu, unsigned int limit);
 u32 leon_cycles_offset(void);
-
-#ifdef CONFIG_SMP
-
-/* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
-#define SUN4D_IPI_IRQ 13
-
-void sun4d_ipi_interrupt(void);
-
-#endif
+void leon_nmi(struct pt_regs *regs);
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index f76f57073323..5bd64828e8a0 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -111,7 +111,7 @@ static struct irq_bucket irq_table[NR_IRQS];
 static DEFINE_SPINLOCK(irq_table_lock);
 
 /* Map between the irq identifier used in hw to the irq_bucket. */
-struct irq_bucket *irq_map[SUN4D_MAX_IRQ];
+struct irq_bucket *irq_map[MAX_IRQ];
 /* Protect access to i

[PATCH 04/27] sparc32: Drop sun4m specific led driver

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The led driver is only relevant for the sun4m machines.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig |   9 ---
 arch/sparc/kernel/Makefile |   1 -
 arch/sparc/kernel/led.c| 146 -
 3 files changed, 156 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 54c91431724b..1520f68e944a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -331,15 +331,6 @@ config SUN_PM
  Enable power management and CPU standby features on supported
  SPARC platforms.
 
-config SPARC_LED
-   tristate "Sun4m LED driver"
-   depends on SPARC32
-   help
- This driver toggles the front-panel LED on sun4m systems
- in a user-specifiable manner.  Its state can be probed
- by reading /proc/led and its blinking mode can be changed
- via writes to /proc/led
-
 config SERIAL_CONSOLE
bool
depends on SPARC32
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 0984bb6f0f17..95687af45d20 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -90,7 +90,6 @@ obj-y += termios.o
 
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_MODULES) += sparc_ksyms.o
-obj-$(CONFIG_SPARC_LED)   += led.o
 obj-$(CONFIG_KGDB)+= kgdb_$(BITS).o
 
 obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c
deleted file mode 100644
index ab657b359789..
--- a/arch/sparc/kernel/led.c
+++ /dev/null
@@ -1,146 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#define LED_MAX_LENGTH 8 /* maximum chars written to proc file */
-
-static inline void led_toggle(void)
-{
-   unsigned char val = get_auxio();
-   unsigned char on, off;
-
-   if (val & AUXIO_LED) {
-   on = 0;
-   off = AUXIO_LED;
-   } else {
-   on = AUXIO_LED;
-   off = 0;
-   }
-
-   set_auxio(on, off);
-}
-
-static struct timer_list led_blink_timer;
-static unsigned long led_blink_timer_timeout;
-
-static void led_blink(struct timer_list *unused)
-{
-   unsigned long timeout = led_blink_timer_timeout;
-
-   led_toggle();
-
-   /* reschedule */
-   if (!timeout) { /* blink according to load */
-   led_blink_timer.expires = jiffies +
-   ((1 + (avenrun[0] >> FSHIFT)) * HZ);
-   } else { /* blink at user specified interval */
-   led_blink_timer.expires = jiffies + (timeout * HZ);
-   }
-   add_timer(_blink_timer);
-}
-
-#ifdef CONFIG_PROC_FS
-static int led_proc_show(struct seq_file *m, void *v)
-{
-   if (get_auxio() & AUXIO_LED)
-   seq_puts(m, "on\n");
-   else
-   seq_puts(m, "off\n");
-   return 0;
-}
-
-static int led_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, led_proc_show, NULL);
-}
-
-static ssize_t led_proc_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
-   char *buf = NULL;
-
-   if (count > LED_MAX_LENGTH)
-   count = LED_MAX_LENGTH;
-
-   buf = memdup_user_nul(buffer, count);
-   if (IS_ERR(buf))
-   return PTR_ERR(buf);
-
-   /* work around \n when echo'ing into proc */
-   if (buf[count - 1] == '\n')
-   buf[count - 1] = '\0';
-
-   /* before we change anything we want to stop any running timers,
-* otherwise calls such as on will have no persistent effect
-*/
-   del_timer_sync(_blink_timer);
-
-   if (!strcmp(buf, "on")) {
-   auxio_set_led(AUXIO_LED_ON);
-   } else if (!strcmp(buf, "toggle")) {
-   led_toggle();
-   } else if ((*buf > '0') && (*buf <= '9')) {
-   led_blink_timer_timeout = simple_strtoul(buf, NULL, 10);
-   led_blink(_blink_timer);
-   } else if (!strcmp(buf, "load")) {
-   led_blink_timer_timeout = 0;
-   led_blink(_blink_timer);
-   } else {
-   auxio_set_led(AUXIO_LED_OFF);
-   }
-
-   kfree(buf);
-
-   return count;
-}
-
-static const struct proc_ops led_proc_ops = {
-   .proc_open  = led_proc_open,
-   .proc_read  = seq_read,
-   .proc_lseek = seq_lseek,
-   .proc_release   = single_release,
-   .proc_write = led_proc_write,
-};
-#endif
-
-#define LED_VERSION"0.1"
-
-static int __init led_init(void)
-{
-   timer_setup(_blink_timer, led_blink, 0);
-
-#ifdef CONFIG_PROC_FS
-   if (!proc_create("led", 0, NULL, _p

[PATCH 03/27] sparc32: Drop floppy support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

LEON do not have floppy support so we can drop it

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig |   2 +-
 arch/sparc/include/asm/floppy.h|   2 -
 arch/sparc/include/asm/floppy_32.h | 393 -
 arch/sparc/kernel/entry.S  | 137 -
 arch/sparc/kernel/irq.h|   3 -
 arch/sparc/kernel/irq_32.c |  93 -
 arch/sparc/kernel/kernel.h |   2 -
 7 files changed, 1 insertion(+), 631 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 49849790e66d..54c91431724b 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -195,7 +195,7 @@ config GENERIC_CALIBRATE_DELAY
 
 config ARCH_MAY_HAVE_PC_FDC
bool
-   default y
+   default y if SPARC64
 
 config EMULATED_CMPXCHG
bool
diff --git a/arch/sparc/include/asm/floppy.h b/arch/sparc/include/asm/floppy.h
index 4b315802e635..c89f719a18e9 100644
--- a/arch/sparc/include/asm/floppy.h
+++ b/arch/sparc/include/asm/floppy.h
@@ -3,7 +3,5 @@
 #define ___ASM_SPARC_FLOPPY_H
 #if defined(__sparc__) && defined(__arch64__)
 #include 
-#else
-#include 
 #endif
 #endif
diff --git a/arch/sparc/include/asm/floppy_32.h 
b/arch/sparc/include/asm/floppy_32.h
deleted file mode 100644
index 836f6575aa1d..
--- a/arch/sparc/include/asm/floppy_32.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* asm/floppy.h: Sparc specific parts of the Floppy driver.
- *
- * Copyright (C) 1995 David S. Miller (da...@davemloft.net)
- */
-
-#ifndef __ASM_SPARC_FLOPPY_H
-#define __ASM_SPARC_FLOPPY_H
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* We don't need no stinkin' I/O port allocation crap. */
-#undef release_region
-#undef request_region
-#define release_region(X, Y)   do { } while(0)
-#define request_region(X, Y, Z)(1)
-
-/* References:
- * 1) Netbsd Sun floppy driver.
- * 2) NCR 82077 controller manual
- * 3) Intel 82077 controller manual
- */
-struct sun_flpy_controller {
-   volatile unsigned char status_82072;  /* Main Status reg. */
-#define dcr_82072  status_82072   /* Digital Control reg. */
-#define status1_82077  status_82072   /* Auxiliary Status reg. 1 */
-
-   volatile unsigned char data_82072;/* Data fifo. */
-#define status2_82077  data_82072 /* Auxiliary Status reg. 2 */
-
-   volatile unsigned char dor_82077; /* Digital Output reg. */
-   volatile unsigned char tapectl_82077; /* What the? Tape control reg? */
-
-   volatile unsigned char status_82077;  /* Main Status Register. */
-#define drs_82077  status_82077   /* Digital Rate Select reg. */
-
-   volatile unsigned char data_82077;/* Data fifo. */
-   volatile unsigned char ___unused;
-   volatile unsigned char dir_82077; /* Digital Input reg. */
-#define dcr_82077  dir_82077  /* Config Control reg. */
-};
-
-/* You'll only ever find one controller on a SparcStation anyways. */
-static struct sun_flpy_controller *sun_fdc = NULL;
-
-struct sun_floppy_ops {
-   unsigned char (*fd_inb)(int port);
-   void (*fd_outb)(unsigned char value, int port);
-};
-
-static struct sun_floppy_ops sun_fdops;
-
-#define fd_inb(base, reg) sun_fdops.fd_inb(reg)
-#define fd_outb(value, base, reg) sun_fdops.fd_outb(value, reg)
-#define fd_enable_dma()   sun_fd_enable_dma()
-#define fd_disable_dma()  sun_fd_disable_dma()
-#define fd_request_dma()  (0) /* nothing... */
-#define fd_free_dma() /* nothing... */
-#define fd_clear_dma_ff() /* nothing... */
-#define fd_set_dma_mode(mode) sun_fd_set_dma_mode(mode)
-#define fd_set_dma_addr(addr) sun_fd_set_dma_addr(addr)
-#define fd_set_dma_count(count)   sun_fd_set_dma_count(count)
-#define fd_enable_irq()   /* nothing... */
-#define fd_disable_irq()  /* nothing... */
-#define fd_request_irq()  sun_fd_request_irq()
-#define fd_free_irq() /* nothing... */
-#if 0  /* P3: added by Alain, these cause a MMU corruption. 19960524 XXX */
-#define fd_dma_mem_alloc(size)((unsigned long) vmalloc(size))
-#define fd_dma_mem_free(addr,size) (vfree((void *)(addr)))
-#endif
-
-/* XXX This isn't really correct. XXX */
-#define get_dma_residue(x)(0)
-
-#define FLOPPY0_TYPE  4
-#define FLOPPY1_TYPE  0
-
-/* Super paranoid... */
-#undef HAVE_DISABLE_HLT
-
-/* Here is where we catch the floppy driver trying to initialize,
- * therefore this is where we call the PROM device tree probing
- * routine etc. on the Sparc.
- */
-#define FDC1  sun_floppy_init()
-
-#define N_FDC1
-#define N_DRIVE  8
-
-/* No 64k boundary crossing problems on the Sparc. */
-#define CROSS_64KB(a,s) (0)
-
-/* Routines unique to each controller type on a Su

[PATCH 01/27] sparc32: Update defconfig to LEON SMP

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

This is a copy of the leon_smp defconfig found in
gaisler-buildroot-2023.02-1.0.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/configs/sparc32_defconfig | 171 +++
 1 file changed, 91 insertions(+), 80 deletions(-)

diff --git a/arch/sparc/configs/sparc32_defconfig 
b/arch/sparc/configs/sparc32_defconfig
index 5010164de3e4..71273fc578bf 100644
--- a/arch/sparc/configs/sparc32_defconfig
+++ b/arch/sparc/configs/sparc32_defconfig
@@ -1,97 +1,108 @@
+CONFIG_DEFAULT_HOSTNAME="leon"
 CONFIG_SYSVIPC=y
-CONFIG_POSIX_MQUEUE=y
 CONFIG_LOG_BUF_SHIFT=14
-CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_BLK_DEV_INITRD=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_BLK_DEV_BSG is not set
-CONFIG_PCI=y
-CONFIG_SUN_OPENPROMFS=m
-CONFIG_BINFMT_MISC=m
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+# CONFIG_RD_ZSTD is not set
+CONFIG_SMP=y
+CONFIG_HZ_100=y
+CONFIG_SPARC_LEON=y
+CONFIG_SUN_OPENPROMFS=y
+CONFIG_SUN_OPENPROMIO=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_MISC=y
+# CONFIG_COMPACTION is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
-CONFIG_XFRM_USER=m
-CONFIG_NET_KEY=m
 CONFIG_INET=y
 CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_INET_AH=y
-CONFIG_INET_ESP=y
-CONFIG_INET_IPCOMP=y
-CONFIG_INET6_AH=m
-CONFIG_INET6_ESP=m
-CONFIG_INET6_IPCOMP=m
-CONFIG_IPV6_TUNNEL=m
-CONFIG_NET_PKTGEN=m
-CONFIG_BLK_DEV_LOOP=m
-CONFIG_BLK_DEV_CRYPTOLOOP=m
-CONFIG_BLK_DEV_RAM=y
-CONFIG_SCSI=y
-CONFIG_BLK_DEV_SD=y
-CONFIG_BLK_DEV_SR=m
-CONFIG_CHR_DEV_SG=m
-CONFIG_SCSI_QLOGICPTI=m
-CONFIG_SCSI_SUNESP=y
+# CONFIG_WIRELESS is not set
+CONFIG_UEVENT_HELPER=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_NETDEVICES=y
-CONFIG_DUMMY=m
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=m
-CONFIG_SUNLANCE=y
-CONFIG_HAPPYMEAL=m
-CONFIG_SUNBMAC=m
-CONFIG_SUNQE=m
+CONFIG_GRETH=y
+# CONFIG_NET_VENDOR_ALACRITECH is not set
+# CONFIG_NET_VENDOR_AMAZON is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_AQUANTIA is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CADENCE is not set
+# CONFIG_NET_VENDOR_CAVIUM is not set
+# CONFIG_NET_VENDOR_CORTINA is not set
+# CONFIG_NET_VENDOR_EZCHIP is not set
+# CONFIG_NET_VENDOR_GOOGLE is not set
+# CONFIG_NET_VENDOR_HUAWEI is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_MICROSEMI is not set
+# CONFIG_NET_VENDOR_NI is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_NET_VENDOR_PENSANDO is not set
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_RENESAS is not set
+# CONFIG_NET_VENDOR_ROCKER is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
+# CONFIG_NET_VENDOR_SOCIONEXT is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_SUN is not set
+# CONFIG_NET_VENDOR_SYNOPSYS is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+# CONFIG_NET_VENDOR_XILINX is not set
+CONFIG_BROADCOM_PHY=y
+CONFIG_CICADA_PHY=y
+CONFIG_DAVICOM_PHY=y
+CONFIG_ICPLUS_PHY=y
+CONFIG_LXT_PHY=y
+CONFIG_LSI_ET1011C_PHY=y
+CONFIG_MARVELL_PHY=y
+CONFIG_MICREL_PHY=y
+CONFIG_NATIONAL_PHY=y
+CONFIG_QSEMI_PHY=y
+CONFIG_REALTEK_PHY=y
+CONFIG_SMSC_PHY=y
+CONFIG_STE10XP=y
+CONFIG_VITESSE_PHY=y
 # CONFIG_WLAN is not set
-CONFIG_INPUT_JOYDEV=m
-CONFIG_INPUT_EVDEV=m
-CONFIG_INPUT_EVBUG=m
-CONFIG_KEYBOARD_ATKBD=m
-CONFIG_KEYBOARD_SUNKBD=m
-CONFIG_MOUSE_PS2=m
-CONFIG_MOUSE_SERIAL=m
-CONFIG_SERIO=m
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIAL_SUNZILOG=y
 CONFIG_SERIAL_SUNZILOG_CONSOLE=y
-CONFIG_SERIAL_SUNSU=y
-CONFIG_SERIAL_SUNSU_CONSOLE=y
-CONFIG_SPI=y
-CONFIG_SPI_XILINX=m
-CONFIG_SPI_XILINX_PLTFM=m
-CONFIG_SUN_OPENPROMIO=m
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-CONFIG_EXT2_FS_SECURITY=y
-CONFIG_AUTOFS_FS=m
-CONFIG_ISO9660_FS=m
+CONFIG_SERIAL_GRLIB_GAISLER_APBUART=y
+CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_HID_GENERIC is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_RTC_HCTOSYS is not set
+# CONFIG_RTC_INTF_SYSFS is not set
+# CONFIG_RTC_INTF_PROC is not set
+# CONFIG_RTC_INTF_DEV is not set
+# CONFIG_VIRTIO_MENU is not set
+# CONFIG_VHOST_MENU is not set
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_FSCACHE=y
 CONFIG_PROC_KCORE=y
-CONFIG_ROMFS_FS=m
+CONFIG_TMPFS=y
+# CONFIG_MISC_FILESYSTEMS is not set
 CONFIG_NFS_FS=y
+CONFIG_NFS_V4=y
 CONFIG_ROOT_NFS=y
-CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_NFS_FSC

[PATCH 11/27] sparc32: Drop pcic support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

pcic is only used by MicroSPARC-IIep and not relevant for LEON.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig|   5 -
 arch/sparc/include/asm/pcic.h | 130 ---
 arch/sparc/kernel/Makefile|   1 -
 arch/sparc/kernel/entry.S |  48 ---
 arch/sparc/kernel/irq_32.c|   1 -
 arch/sparc/kernel/kernel.h|   4 -
 arch/sparc/kernel/pcic.c  | 829 --
 arch/sparc/kernel/time_32.c   |   6 +-
 8 files changed, 1 insertion(+), 1023 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 55a9e67c482e..7ae304bab2d8 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -414,11 +414,6 @@ config SUN_LDOMS
  Say Y here is you want to support virtual devices via
  Logical Domains.
 
-config PCIC_PCI
-   bool
-   depends on PCI && SPARC32 && !SPARC_LEON
-   default y
-
 config LEON_PCI
bool
depends on PCI && SPARC_LEON
diff --git a/arch/sparc/include/asm/pcic.h b/arch/sparc/include/asm/pcic.h
deleted file mode 100644
index 238376b1ffcc..
--- a/arch/sparc/include/asm/pcic.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * pcic.h: JavaEngine 1 specific PCI definitions.
- *
- * Copyright (C) 1998 V. Roganov and G. Raiko
- */
-
-#ifndef __SPARC_PCIC_H
-#define __SPARC_PCIC_H
-
-#ifndef __ASSEMBLY__
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-struct linux_pcic {
-void __iomem*pcic_regs;
-unsigned long   pcic_io;
-void __iomem*pcic_config_space_addr;
-void __iomem*pcic_config_space_data;
-   struct resource pcic_res_regs;
-   struct resource pcic_res_io;
-   struct resource pcic_res_cfg_addr;
-   struct resource pcic_res_cfg_data;
-struct linux_pbm_info   pbm;
-   struct pcic_ca2irq  *pcic_imap;
-   int pcic_imdim;
-};
-
-#ifdef CONFIG_PCIC_PCI
-int pcic_present(void);
-int pcic_probe(void);
-void pci_time_init(void);
-void sun4m_pci_init_IRQ(void);
-#else
-static inline int pcic_present(void) { return 0; }
-static inline int pcic_probe(void) { return 0; }
-static inline void pci_time_init(void) {}
-static inline void sun4m_pci_init_IRQ(void) {}
-#endif
-#endif
-
-/* Size of PCI I/O space which we relocate. */
-#define PCI_SPACE_SIZE  0x100   /* 16 MB */
-
-/* PCIC Register Set. */
-#define PCI_DIAGNOSTIC_00x40/* 32 bits */
-#define PCI_SIZE_0  0x44/* 32 bits */
-#define PCI_SIZE_1  0x48/* 32 bits */
-#define PCI_SIZE_2  0x4c/* 32 bits */
-#define PCI_SIZE_3  0x50/* 32 bits */
-#define PCI_SIZE_4  0x54/* 32 bits */
-#define PCI_SIZE_5  0x58/* 32 bits */
-#define PCI_PIO_CONTROL 0x60/* 8  bits */
-#define PCI_DVMA_CONTROL0x62/* 8  bits */
-#define  PCI_DVMA_CONTROL_INACTIVITY_REQ(1<<0)
-#define  PCI_DVMA_CONTROL_IOTLB_ENABLE  (1<<0)
-#define  PCI_DVMA_CONTROL_IOTLB_DISABLE 0
-#define  PCI_DVMA_CONTROL_INACTIVITY_ACK(1<<4)
-#define PCI_INTERRUPT_CONTROL   0x63/* 8  bits */
-#define PCI_CPU_INTERRUPT_PENDING   0x64/* 32 bits */
-#define PCI_DIAGNOSTIC_10x68/* 16 bits */
-#define PCI_SOFTWARE_INT_CLEAR  0x6a/* 16 bits */
-#define PCI_SOFTWARE_INT_SET0x6e/* 16 bits */
-#define PCI_SYS_INT_PENDING 0x70/* 32 bits */
-#define  PCI_SYS_INT_PENDING_PIO   0x4000
-#define  PCI_SYS_INT_PENDING_DMA   0x2000
-#define  PCI_SYS_INT_PENDING_PCI   0x1000
-#define  PCI_SYS_INT_PENDING_APSR  0x0800
-#define PCI_SYS_INT_TARGET_MASK 0x74/* 32 bits */
-#define PCI_SYS_INT_TARGET_MASK_CLEAR   0x78/* 32 bits */
-#define PCI_SYS_INT_TARGET_MASK_SET 0x7c/* 32 bits */
-#define PCI_SYS_INT_PENDING_CLEAR   0x83/* 8  bits */
-#define  PCI_SYS_INT_PENDING_CLEAR_ALL 0x80
-#define  PCI_SYS_INT_PENDING_CLEAR_PIO 0x40
-#define  PCI_SYS_INT_PENDING_CLEAR_DMA 0x20
-#define  PCI_SYS_INT_PENDING_CLEAR_PCI 0x10
-#define PCI_IOTLB_CONTROL   0x84/* 8  bits */
-#define PCI_INT_SELECT_LO   0x88/* 16 bits */
-#define PCI_ARBITRATION_SELECT  0x8a/* 16 bits */
-#define PCI_INT_SELECT_HI   0x8c/* 16 bits */
-#define PCI_HW_INT_OUTPUT   0x8e/* 16 bits */
-#define PCI_IOTLB_RAM_INPUT 0x90/* 32 bits */
-#define PCI_IOTLB_CAM_INPUT 0x94/* 32 bits */
-#define PCI_IOTLB_RAM_OUTPUT0x98/* 32 bits */
-#defin

[PATCH 09/27] sparc32: Drop sun4m/sun4d specific irq handling

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Some of the sun4m irq infrastructure is used by LEON too,
so keep that and drop the rest.
The patch include a few extra fixes fix the build after
the removal of the irq support.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/irq_32.h |   2 -
 arch/sparc/kernel/Makefile  |   2 +-
 arch/sparc/kernel/irq_32.c  |  30 +--
 arch/sparc/kernel/kernel.h  |  13 --
 arch/sparc/kernel/sun4d_irq.c   | 494 
 arch/sparc/kernel/sun4d_smp.c   |   4 -
 arch/sparc/kernel/sun4m_irq.c   | 240 ---
 arch/sparc/mm/io-unit.c |   2 -
 8 files changed, 2 insertions(+), 785 deletions(-)

diff --git a/arch/sparc/include/asm/irq_32.h b/arch/sparc/include/asm/irq_32.h
index 6ee48321cbc2..c402c81b85a7 100644
--- a/arch/sparc/include/asm/irq_32.h
+++ b/arch/sparc/include/asm/irq_32.h
@@ -17,8 +17,6 @@
 
 #define irq_canonicalize(irq)  (irq)
 
-void __init sun4d_init_sbi_irq(void);
-
 #define NO_IRQ 0x
 
 #endif
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 577cb57c588a..e79ef2049ea2 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -29,7 +29,7 @@ obj-y   += traps_$(BITS).o
 
 # IRQ
 obj-y   += irq_$(BITS).o
-obj-$(CONFIG_SPARC32)   += sun4m_irq.o sun4d_irq.o
+obj-$(CONFIG_SPARC32)   += sun4m_irq.o
 
 obj-y   += process_$(BITS).o
 obj-y   += process.o
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index 510184c3aa17..135170f362c1 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -235,36 +235,8 @@ void handler_irq(unsigned int pil, struct pt_regs *regs)
set_irq_regs(old_regs);
 }
 
-/* djhr
- * This could probably be made indirect too and assigned in the CPU
- * bits of the code. That would be much nicer I think and would also
- * fit in with the idea of being able to tune your kernel for your machine
- * by removing unrequired machine and device support.
- *
- */
-
 void __init init_IRQ(void)
 {
-   switch (sparc_cpu_model) {
-   case sun4m:
-   pcic_probe();
-   if (pcic_present())
-   sun4m_pci_init_IRQ();
-   else
-   sun4m_init_IRQ();
-   break;
-
-   case sun4d:
-   sun4d_init_IRQ();
-   break;
-
-   case sparc_leon:
-   leon_init_IRQ();
-   break;
-
-   default:
-   prom_printf("Cannot initialize IRQs on this Sun machine...");
-   break;
-   }
+   leon_init_IRQ();
 }
 
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 85a3c3d1195e..f090d34a2f56 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -93,7 +93,6 @@ extern spinlock_t irq_action_lock;
 void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs);
 
 /* sun4m_irq.c */
-void sun4m_init_IRQ(void);
 void sun4m_unmask_profile_irq(void);
 void sun4m_clear_profile_irq(int cpu);
 
@@ -106,18 +105,6 @@ void __init smp4m_smp_done(void);
 void smp4m_cross_call_irq(void);
 void smp4m_percpu_timer_interrupt(struct pt_regs *regs);
 
-/* sun4d_irq.c */
-extern spinlock_t sun4d_imsk_lock;
-
-void sun4d_init_IRQ(void);
-int sun4d_request_irq(unsigned int irq,
-  irq_handler_t handler,
-  unsigned long irqflags,
-  const char *devname, void *dev_id);
-int show_sun4d_interrupts(struct seq_file *, void *);
-void sun4d_distribute_irqs(void);
-void sun4d_free_irq(unsigned int irq, void *dev_id);
-
 /* sun4d_smp.c */
 void sun4d_cpu_pre_starting(void *arg);
 void sun4d_cpu_pre_online(void *arg);
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
deleted file mode 100644
index 7140cff04b54..
--- a/arch/sparc/kernel/sun4d_irq.c
+++ /dev/null
@@ -1,494 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * SS1000/SC2000 interrupt handling.
- *
- *  Copyright (C) 1997,1998 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
- *  Heavily based on arch/sparc/kernel/irq.c.
- */
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "kernel.h"
-#include "irq.h"
-
-/* Sun4d interrupts fall roughly into two categories.  SBUS and
- * cpu local.  CPU local interrupts cover the timer interrupts
- * and whatnot, and we encode those as normal PILs between
- * 0 and 15.
- * SBUS interrupts are encodes as a combination of board, level and slot.
- */
-
-struct sun4d_handler_data {
-   unsigned int cpuid;/* target cpu */
-   unsigned int real_irq; /* interrupt level */
-};
-
-
-static unsigned int sun4d_encode_irq(int board, int lvl, int slot)
-{
-   return (board + 1) << 5 | (lvl << 2)

[PATCH 10/27] sparc32: Drop sun4d/sun4m smp support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the sun4m and sun4d smp support code.

The sparc32 kernel will not boot unless this is a LEON system,
so drop checks for other systems as they will not trigger.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/Makefile|   2 +-
 arch/sparc/kernel/kernel.h|  18 --
 arch/sparc/kernel/smp_32.c| 102 +--
 arch/sparc/kernel/sun4d_smp.c | 408 --
 arch/sparc/kernel/sun4m_smp.c | 275 
 arch/sparc/mm/srmmu.c |  10 +-
 6 files changed, 8 insertions(+), 807 deletions(-)

diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index e79ef2049ea2..386bbb30fff2 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -80,7 +80,7 @@ obj-$(CONFIG_SPARC_GRPCI2)+= leon_pci_grpci2.o
 obj-$(CONFIG_SPARC_GRPCI1)+= leon_pci_grpci1.o
 
 obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o
-obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
+obj-$(CONFIG_SPARC32_SMP) += leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
 obj-$(CONFIG_SPARC64) += auxio_64.o
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index f090d34a2f56..ff8f412e3153 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -96,24 +96,6 @@ void unexpected_irq(int irq, void *dev_id, struct pt_regs * 
regs);
 void sun4m_unmask_profile_irq(void);
 void sun4m_clear_profile_irq(int cpu);
 
-/* sun4m_smp.c */
-void sun4m_cpu_pre_starting(void *arg);
-void sun4m_cpu_pre_online(void *arg);
-void __init smp4m_boot_cpus(void);
-int smp4m_boot_one_cpu(int i, struct task_struct *idle);
-void __init smp4m_smp_done(void);
-void smp4m_cross_call_irq(void);
-void smp4m_percpu_timer_interrupt(struct pt_regs *regs);
-
-/* sun4d_smp.c */
-void sun4d_cpu_pre_starting(void *arg);
-void sun4d_cpu_pre_online(void *arg);
-void __init smp4d_boot_cpus(void);
-int smp4d_boot_one_cpu(int i, struct task_struct *idle);
-void __init smp4d_smp_done(void);
-void smp4d_cross_call_irq(void);
-void smp4d_percpu_timer_interrupt(struct pt_regs *regs);
-
 /* leon_smp.c */
 void leon_cpu_pre_starting(void *arg);
 void leon_cpu_pre_online(void *arg);
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 87eaa7719fa2..42fb90577a82 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -87,29 +87,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
num, bogosum/(50/HZ),
(bogosum/(5000/HZ))%100);
 
-   switch(sparc_cpu_model) {
-   case sun4m:
-   smp4m_smp_done();
-   break;
-   case sun4d:
-   smp4d_smp_done();
-   break;
-   case sparc_leon:
-   leon_smp_done();
-   break;
-   case sun4e:
-   printk("SUN4E\n");
-   BUG();
-   break;
-   case sun4u:
-   printk("SUN4U\n");
-   BUG();
-   break;
-   default:
-   printk("UNKNOWN!\n");
-   BUG();
-   break;
-   }
+   leon_smp_done();
 }
 
 void cpu_panic(void)
@@ -191,29 +169,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 
smp_store_cpu_info(boot_cpu_id);
 
-   switch(sparc_cpu_model) {
-   case sun4m:
-   smp4m_boot_cpus();
-   break;
-   case sun4d:
-   smp4d_boot_cpus();
-   break;
-   case sparc_leon:
-   leon_boot_cpus();
-   break;
-   case sun4e:
-   printk("SUN4E\n");
-   BUG();
-   break;
-   case sun4u:
-   printk("SUN4U\n");
-   BUG();
-   break;
-   default:
-   printk("UNKNOWN!\n");
-   BUG();
-   break;
-   }
+   leon_boot_cpus();
 }
 
 /* Set this up early so that things like the scheduler can init
@@ -252,31 +208,7 @@ void __init smp_prepare_boot_cpu(void)
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
-   int ret=0;
-
-   switch(sparc_cpu_model) {
-   case sun4m:
-   ret = smp4m_boot_one_cpu(cpu, tidle);
-   break;
-   case sun4d:
-   ret = smp4d_boot_one_cpu(cpu, tidle);
-   break;
-   case sparc_leon:
-   ret = leon_boot_one_cpu(cpu, tidle);
-   break;
-   case sun4e:
-   printk("SUN4E\n");
-   BUG();
-   break;
-   case sun4u:
-   printk("SUN4U\n");
-   BUG();
-   break;
-   default:
-   printk("UNKNOWN!\n");
-   BUG();
-   break;
-   }
+   int ret = leon_boot_one_cpu(cpu, tidle);
 
   

[PATCH 23/27] sparc32: Drop unused trampoline code

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the sun4m and sun4d code from trampoline_32

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/kernel.h|   3 +-
 arch/sparc/kernel/trampoline_32.S | 127 +-
 2 files changed, 3 insertions(+), 127 deletions(-)

diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 30adbec894f7..aea96b6b881c 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -112,8 +112,7 @@ extern unsigned int real_irq_entry[];
 extern unsigned int smp4d_ticker[];
 
 /* trampoline_32.S */
-extern unsigned long sun4m_cpu_startup;
-extern unsigned long sun4d_cpu_startup;
+void leon_smp_cpu_startup(int boot_cpu);
 
 /* signal_32.c */
 asmlinkage void do_sigreturn(struct pt_regs *regs);
diff --git a/arch/sparc/kernel/trampoline_32.S 
b/arch/sparc/kernel/trampoline_32.S
index 82fafeeb3a62..685b20923f6b 100644
--- a/arch/sparc/kernel/trampoline_32.S
+++ b/arch/sparc/kernel/trampoline_32.S
@@ -15,136 +15,12 @@
 #include 
 #include 
 
-   .globl sun4m_cpu_startup
-   .globl sun4d_cpu_startup
-
-   .align 4
-
 /* When we start up a cpu for the first time it enters this routine.
  * This initializes the chip from whatever state the prom left it
  * in and sets PIL in %psr to 15, no irqs.
  */
-
-sun4m_cpu_startup:
-cpu1_startup:
-   sethi   %hi(trapbase_cpu1), %g3
-   b   1f
-or %g3, %lo(trapbase_cpu1), %g3
-
-cpu2_startup:
-   sethi   %hi(trapbase_cpu2), %g3
-   b   1f
-or %g3, %lo(trapbase_cpu2), %g3
-
-cpu3_startup:
-   sethi   %hi(trapbase_cpu3), %g3
-   b   1f
-or %g3, %lo(trapbase_cpu3), %g3
-
-1:
-   /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
-   set (PSR_PIL | PSR_S | PSR_PS), %g1
-   wr  %g1, 0x0, %psr  ! traps off though
-   WRITE_PAUSE
-
-   /* Our %wim is one behind CWP */
-   mov 2, %g1
-   wr  %g1, 0x0, %wim
-   WRITE_PAUSE
-
-   /* This identifies "this cpu". */
-   wr  %g3, 0x0, %tbr
-   WRITE_PAUSE
-
-   /* Give ourselves a stack and curptr. */
-   set current_set, %g5
-   srl %g3, 10, %g4
-   and %g4, 0xc, %g4
-   ld  [%g5 + %g4], %g6
-
-   sethi   %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
-   or  %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
-   add %g6, %sp, %sp
-
-   /* Turn on traps (PSR_ET). */
-   rd  %psr, %g1
-   wr  %g1, PSR_ET, %psr   ! traps on
-   WRITE_PAUSE
-
-   /* Init our caches, etc. */
-   set poke_srmmu, %g5
-   ld  [%g5], %g5
-   call%g5
-nop
-
-   /* Start this processor. */
-   callsmp_callin
-nop
-
-   b,a smp_panic
-
.text
.align  4
-
-smp_panic:
-   callcpu_panic
-nop
-
-/* CPUID in bootbus can be found at PA 0xff014 */
-#define SUN4D_BOOTBUS_CPUID0xf014
-
-   .align  4
-
-sun4d_cpu_startup:
-   /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
-   set (PSR_PIL | PSR_S | PSR_PS), %g1
-   wr  %g1, 0x0, %psr  ! traps off though
-   WRITE_PAUSE
-
-   /* Our %wim is one behind CWP */
-   mov 2, %g1
-   wr  %g1, 0x0, %wim
-   WRITE_PAUSE
-
-   /* Set tbr - we use just one trap table. */
-   set trapbase, %g1
-   wr  %g1, 0x0, %tbr
-   WRITE_PAUSE
-
-   /* Get our CPU id out of bootbus */
-   set SUN4D_BOOTBUS_CPUID, %g3
-   lduba   [%g3] ASI_M_CTL, %g3
-   and %g3, 0xf8, %g3
-   srl %g3, 3, %g1
-   sta %g1, [%g0] ASI_M_VIKING_TMP1
-
-   /* Give ourselves a stack and curptr. */
-   set current_set, %g5
-   srl %g3, 1, %g4
-   ld  [%g5 + %g4], %g6
-
-   sethi   %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
-   or  %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
-   add %g6, %sp, %sp
-
-   /* Turn on traps (PSR_ET). */
-   rd  %psr, %g1
-   wr  %g1, PSR_ET, %psr   ! traps on
-   WRITE_PAUSE
-
-   /* Init our caches, etc. */
-   set poke_srmmu, %g5
-   ld  [%g5], %g5
-   call%g5
-nop
-
-   /* Start this processor. */
-   callsmp_callin
-nop
-
-   b,a smp_panic
-
-   .align  4
 .global leon_smp_cpu_startup, smp_penguin_ctable
 
 leon_smp_cpu_startup:
@@ -198,4 +74,5 @@ leon_smp_cpu_startup:
callsmp_callin
 nop
 
-   b,a smp_panic
+   b,a cpu_panic
+nop

-- 
2.34.1



[PATCH 27/27] fbdev/p9100: Drop now unused driver p9100

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The p9100 driver is only relevant for the Sparcbook 3 machine,
and with sun4m support removed this driver is no longer relevant.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
Cc: Helge Deller 
---
 drivers/video/fbdev/Kconfig  |   8 -
 drivers/video/fbdev/Makefile |   1 -
 drivers/video/fbdev/p9100.c  | 372 ---
 3 files changed, 381 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 94f6dca5856f..ebcc3815c7a5 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -576,14 +576,6 @@ config FB_CG14
  This is the frame buffer device driver for the CGfourteen frame
  buffer on Desktop SPARCsystems with the SX graphics option.
 
-config FB_P9100
-   bool "P9100 (Sparcbook 3 only) support"
-   depends on FB_SBUS
-   select FB_SBUS_HELPERS
-   help
- This is the frame buffer device driver for the P9100 card
- supported on Sparcbook 3 machines.
-
 config FB_LEO
bool "Leo (ZX) support"
depends on FB_SBUS
diff --git a/drivers/video/fbdev/Makefile b/drivers/video/fbdev/Makefile
index 8e15220152bd..bc9b24648347 100644
--- a/drivers/video/fbdev/Makefile
+++ b/drivers/video/fbdev/Makefile
@@ -51,7 +51,6 @@ obj-$(CONFIG_FB_CG6)  += cg6.o
 obj-$(CONFIG_FB_CG3)  += cg3.o
 obj-$(CONFIG_FB_BW2)  += bw2.o
 obj-$(CONFIG_FB_CG14) += cg14.o
-obj-$(CONFIG_FB_P9100)+= p9100.o
 obj-$(CONFIG_FB_TCX)  += tcx.o
 obj-$(CONFIG_FB_LEO)  += leo.o
 obj-$(CONFIG_FB_ACORN)+= acornfb.o
diff --git a/drivers/video/fbdev/p9100.c b/drivers/video/fbdev/p9100.c
deleted file mode 100644
index e1356f8a866e..
--- a/drivers/video/fbdev/p9100.c
+++ /dev/null
@@ -1,372 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* p9100.c: P9100 frame buffer driver
- *
- * Copyright (C) 2003, 2006 David S. Miller (da...@davemloft.net)
- * Copyright 1999 Derrick J Brashear (sha...@dementia.org)
- *
- * Driver layout based loosely on tgafb.c, see that file for credits.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-
-#include "sbuslib.h"
-
-/*
- * Local functions.
- */
-
-static int p9100_setcolreg(unsigned, unsigned, unsigned, unsigned,
-  unsigned, struct fb_info *);
-static int p9100_blank(int, struct fb_info *);
-
-static int p9100_sbusfb_mmap(struct fb_info *info, struct vm_area_struct *vma);
-static int p9100_sbusfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned 
long arg);
-
-/*
- *  Frame buffer operations
- */
-
-static const struct fb_ops p9100_ops = {
-   .owner  = THIS_MODULE,
-   FB_DEFAULT_SBUS_OPS(p9100),
-   .fb_setcolreg   = p9100_setcolreg,
-   .fb_blank   = p9100_blank,
-};
-
-/* P9100 control registers */
-#define P9100_SYSCTL_OFF   0x0UL
-#define P9100_VIDEOCTL_OFF 0x100UL
-#define P9100_VRAMCTL_OFF  0x180UL
-#define P9100_RAMDAC_OFF   0x200UL
-#define P9100_VIDEOCOPROC_OFF  0x400UL
-
-/* P9100 command registers */
-#define P9100_CMD_OFF 0x0UL
-
-/* P9100 framebuffer memory */
-#define P9100_FB_OFF 0x0UL
-
-/* 3 bits: 2=8bpp 3=16bpp 5=32bpp 7=24bpp */
-#define SYS_CONFIG_PIXELSIZE_SHIFT 26
-
-#define SCREENPAINT_TIMECTL1_ENABLE_VIDEO 0x20 /* 0 = off, 1 = on */
-
-struct p9100_regs {
-   /* Registers for the system control */
-   u32 sys_base;
-   u32 sys_config;
-   u32 sys_intr;
-   u32 sys_int_ena;
-   u32 sys_alt_rd;
-   u32 sys_alt_wr;
-   u32 sys_xxx[58];
-
-   /* Registers for the video control */
-   u32 vid_base;
-   u32 vid_hcnt;
-   u32 vid_htotal;
-   u32 vid_hsync_rise;
-   u32 vid_hblank_rise;
-   u32 vid_hblank_fall;
-   u32 vid_hcnt_preload;
-   u32 vid_vcnt;
-   u32 vid_vlen;
-   u32 vid_vsync_rise;
-   u32 vid_vblank_rise;
-   u32 vid_vblank_fall;
-   u32 vid_vcnt_preload;
-   u32 vid_screenpaint_addr;
-   u32 vid_screenpaint_timectl1;
-   u32 vid_screenpaint_qsfcnt;
-   u32 vid_screenpaint_timectl2;
-   u32 vid_xxx[15];
-
-   /* Registers for the video control */
-   u32 vram_base;
-   u32 vram_memcfg;
-   u32 vram_refresh_pd;
-   u32 vram_refresh_cnt;
-   u32 vram_raslo_max;
-   u32 vram_raslo_cur;
-   u32 pwrup_cfg;
-   u32 vram_xxx[25];
-
-   /* Registers for IBM RGB528 Palette */
-   u32 ramdac_cmap_wridx;
-   u32 ramdac_palette_data;
-   u32 ramdac_pixel_mask;
-   u32 ramdac_palette_rdaddr;
-   u32 ramdac_idx_lo;
-   u32 ramdac_idx_hi;
-   u32 ramdac_idx_data;
-   u32 ramdac_idx_ctl;
-   u32 ramdac_xxx[1784];
-};
-
-struct p9100_cmd_parameng {
-   u32 parameng_status;

[PATCH 17/27] sparc32: Drop run-time patching of ASI instructions

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

With only LEON supported there is no need to run-time patch
the instructions to match ASI.

Move a few functions back to C with inline asm, now that
run-time patching is not needed.

Deleted a few functions that turns out not to be used rather
than re-implement them in C.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/asmmacro.h | 22 ---
 arch/sparc/include/asm/pgtsrmmu.h | 29 +++---
 arch/sparc/include/asm/sections.h |  3 --
 arch/sparc/include/asm/winmacro.h | 11 +-
 arch/sparc/kernel/entry.S |  7 +---
 arch/sparc/kernel/etrap_32.S  | 15 +++
 arch/sparc/kernel/rtrap_32.S  | 18 +++--
 arch/sparc/kernel/setup_32.c  | 37 -
 arch/sparc/kernel/vmlinux.lds.S   |  5 ---
 arch/sparc/kernel/wof.S   | 18 +++--
 arch/sparc/kernel/wuf.S   | 21 --
 arch/sparc/mm/Makefile|  1 -
 arch/sparc/mm/srmmu_access.S  | 83 ---
 13 files changed, 43 insertions(+), 227 deletions(-)

diff --git a/arch/sparc/include/asm/asmmacro.h 
b/arch/sparc/include/asm/asmmacro.h
index 49aaf6f3bc55..d5782dbc7810 100644
--- a/arch/sparc/include/asm/asmmacro.h
+++ b/arch/sparc/include/asm/asmmacro.h
@@ -21,26 +21,4 @@
 /* All traps low-level code here must end with this macro. */
 #define RESTORE_ALL b ret_trap_entry; clr %l6;
 
-/* Support for run-time patching of single instructions.
- * This is used to handle the differences in the ASI for
- * MMUREGS for LEON and SUN.
- *
- * Sample:
- * LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %o0
- * SUN_PI_(lda [%g0] ASI_M_MMUREGS, %o0
- * PI == Patch Instruction
- *
- * For LEON we will use the first variant,
- * and for all other we will use the SUN variant.
- * The order is important.
- */
-#define LEON_PI(...)   \
-662:   __VA_ARGS__
-
-#define SUN_PI_(...)   \
-   .section .leon_1insn_patch, "ax";   \
-   .word 662b; \
-   __VA_ARGS__;\
-   .previous
-
 #endif /* !(_SPARC_ASMMACRO_H) */
diff --git a/arch/sparc/include/asm/pgtsrmmu.h 
b/arch/sparc/include/asm/pgtsrmmu.h
index 664d4bba1bcb..69c28ff3c4c4 100644
--- a/arch/sparc/include/asm/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
@@ -107,23 +107,24 @@ extern void *srmmu_nocache_pool;
 #define __nocache_va(PADDR) (__va((unsigned long)PADDR) - (unsigned 
long)srmmu_nocache_pool + SRMMU_NOCACHE_VADDR)
 #define __nocache_fix(VADDR) ((__typeof__(VADDR))__va(__nocache_pa(VADDR)))
 
-/* Accessing the MMU control register. */
-unsigned int srmmu_get_mmureg(void);
-void srmmu_set_mmureg(unsigned long regval);
-void srmmu_set_ctable_ptr(unsigned long paddr);
-void srmmu_set_context(int context);
-int srmmu_get_context(void);
-unsigned int srmmu_get_fstatus(void);
-unsigned int srmmu_get_faddr(void);
-
-/* This is guaranteed on all SRMMU's. */
-static inline void srmmu_flush_whole_tlb(void)
+static inline void srmmu_set_ctable_ptr(unsigned long paddr)
 {
-   __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
-"r" (0x400),/* Flush entire TLB!! */
-"i" (ASI_M_FLUSH_PROBE) : "memory");
+   paddr = ((paddr >> 4) & SRMMU_CTX_PMASK);
+   asm volatile("sta %0, [%1] %2\n\t" : : "r" (paddr), "r" 
(SRMMU_CTXTBL_PTR), "i" (ASI_LEON_MMUREGS) : "memory");
+}
+
+static inline void srmmu_set_context(int context)
+{
+   asm volatile("sta %0, [%1] %2\n\t" : : "r" (context), "r" 
(SRMMU_CTX_REG), "i" (ASI_LEON_MMUREGS) : "memory");
+}
 
+static inline int srmmu_get_context(void)
+{
+   register int retval;
+   asm volatile("lda [%1] %2, %0\n\t" : "=r" (retval) : "r" 
(SRMMU_CTX_REG), "i" (ASI_LEON_MMUREGS));
+   return retval;
 }
+
 #endif /* !(__ASSEMBLY__) */
 
 #endif /* !(_SPARC_PGTSRMMU_H) */
diff --git a/arch/sparc/include/asm/sections.h 
b/arch/sparc/include/asm/sections.h
index 08f833453ab3..e9d28148850b 100644
--- a/arch/sparc/include/asm/sections.h
+++ b/arch/sparc/include/asm/sections.h
@@ -8,7 +8,4 @@
 /* sparc entry point */
 extern char _start[];
 
-extern char __leon_1insn_patch[];
-extern char __leon_1insn_patch_end[];
-
 #endif
diff --git a/arch/sparc/include/asm/winmacro.h 
b/arch/sparc/include/asm/winmacro.h
index b6e911f5d93c..c496b04cdfaf 100644
--- a/arch/sparc/include/asm/winmacro.h
+++ b/arch/sparc/include/asm/winmacro.h
@@ -108,18 +108,11 @@
 661:   rd  %tbr, %idreg;   \
srl %idreg, 10, %idreg; \
and %idreg, 0xc, %idreg;\
-   .section.cpuid_patch, "ax"; \
-   /* Instruction 

[PATCH 00/27] sparc32: sunset sun4m and sun4d

2023-12-19 Thread Sam Ravnborg via B4 Relay
This is the second attempt to sunset sun4m and sun4d.
See [1] for the inital attempt.

The sun4m and sun4d parts of the kernel have seen no real interest
for several years now. Last time a few people surfaced, but it was
either due to a personal project or for nostalgic reasons.
It is time to let go and drop the parts of sparc32 that in reality
are not in use.

LEON from Frontgrade Gaisler is the only real user of sparc32,
and this patchset reduces sparc32 to what is required by LEON.

The defconfig is first adapted to the one used by Gaisler.
Then the patches removes sun4m and sun4d specific
implementations such as small drivers, SMP support, IRQ suppor etc.

Removing sun4m and sun4d support allowed removal of the run time
patching of the code as well as a lot of assembler code.
The result is a much cleaner assembler code that is easier to
understand and thus maintain and extend.

So far the code builds but it has seen no run-time testing.

If anyone can tell me how to boot a linux kernel with the leon_genric
machine with QEMU that would be super as this would be a minimal
testing that others can reproduce as well.
I assume QEMU needs a few patches to make it work, but maybe I
just failed to use the right bootloader.

TODO before this can be applied:
- Ack from davem - as he is the principal sparc maintainer
- Tested-by: preferably on a target or QEMU (see above)
  I expect bugs as there are some involved changes!

Ideas for the future
- Apply the most relevant downstream Gaisler patches
  - The ones introducing CAS should have preference as we then
can drop the cmpxchg emulation
- Adjust defconfig to include all Gaisler drivers to make sure they
  see build time coverage
- Move the leon bits from leon files to the general files
  - Add leon smp support to smp_32.c
  - Add leon irq support to irq_32.c
- Integrate leom_mm support with srmmu and drop some of the
  function operations that are no longer needed
- The current sparc32 code assume the bootloader uses the prom
  provided by sun. Maybe migrate over to a more modern device tree
  way of working.
- Drop some of the homegrown memory allocators and use memblocks

[1]: https://lore.kernel.org/all/20201218184347.2180772-1-...@ravnborg.org/

Sam

---
Sam Ravnborg (27):
  sparc32: Update defconfig to LEON SMP
  sparc32: Drop sun4m/sun4d support from head_32.S
  sparc32: Drop floppy support
  sparc32: Drop sun4m specific led driver
  sparc32: Drop sun specific power management drivers
  sparc32: Drop auxio support
  sparc32: Drop run-time patching of ipi trap
  sparc32: Drop patching of interrupt vector
  sparc32: Drop sun4m/sun4d specific irq handling
  sparc32: Drop sun4d/sun4m smp support
  sparc32: Drop pcic support
  sparc32: Drop mbus support
  sparc32: Drop unused function __get_{phys,iospace}
  sparc32: Drop unused mmu models
  sparc32: Drop check for sparc_model
  sparc32: Drop use of sparc_config
  sparc32: Drop run-time patching of ASI instructions
  sparc32: Drop support for 7 register windows
  sparc32: Drop additional sun4d bits
  sparc32: Drop unused prom ranges support
  sparc32: Drop unused iommu support
  sparc32: Drop sun4m irq support
  sparc32: Drop unused trampoline code
  sparc32: Drop config SPARC_LEON
  sparc32: Drop sbus support
  sbus: char: Drop now unused uctrl driver
  fbdev/p9100: Drop now unused driver p9100

 arch/sparc/Kconfig|  54 +--
 arch/sparc/configs/sparc32_defconfig  | 170 +++
 arch/sparc/include/asm/asmmacro.h |  22 -
 arch/sparc/include/asm/auxio_32.h |  73 +--
 arch/sparc/include/asm/cpu_type.h |  18 -
 arch/sparc/include/asm/elf_32.h   |   2 -
 arch/sparc/include/asm/fb.h   |   8 +-
 arch/sparc/include/asm/floppy.h   |   2 -
 arch/sparc/include/asm/floppy_32.h| 393 
 arch/sparc/include/asm/io-unit.h  |  59 ---
 arch/sparc/include/asm/io_32.h|  83 
 arch/sparc/include/asm/iommu.h|   2 -
 arch/sparc/include/asm/iommu_32.h | 122 -
 arch/sparc/include/asm/irq_32.h   |   2 -
 arch/sparc/include/asm/mbus.h |  97 
 arch/sparc/include/asm/mxcc.h | 138 --
 arch/sparc/include/asm/obio.h | 226 -
 arch/sparc/include/asm/oplib_32.h |  11 -
 arch/sparc/include/asm/pcic.h | 130 --
 arch/sparc/include/asm/pgtable_32.h   |  24 -
 arch/sparc/include/asm/pgtsrmmu.h |  33 +-
 arch/sparc/include/asm/ross.h | 192 
 arch/sparc/include/asm/sbi.h  | 116 -
 arch/sparc/include/asm/sections.h |   3 -
 arch/sparc/include/asm/swift.h| 107 -
 arch/sparc/include/asm/switch_to_32.h |   1 -
 arch/sparc/include/asm/timer_32.h |   1 +
 arch/sparc/include/asm/tsunami.h  |  65 ---
 arch/sparc/include/asm/turbosparc.h   | 126 -
 arch/sparc/include/asm/viking.h   | 255 ---
 arch/sparc/include/asm

[PATCH 21/27] sparc32: Drop unused iommu support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

LEON do not have any iommu support - drop it.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/iommu.h|   2 -
 arch/sparc/include/asm/iommu_32.h | 122 ---
 arch/sparc/kernel/ioport.c|   1 -
 arch/sparc/mm/Makefile|   2 +-
 arch/sparc/mm/iommu.c | 420 --
 arch/sparc/mm/mm_32.h |   3 -
 arch/sparc/mm/srmmu.c |   3 -
 7 files changed, 1 insertion(+), 552 deletions(-)

diff --git a/arch/sparc/include/asm/iommu.h b/arch/sparc/include/asm/iommu.h
index 37935cb34865..ea07526ff476 100644
--- a/arch/sparc/include/asm/iommu.h
+++ b/arch/sparc/include/asm/iommu.h
@@ -3,7 +3,5 @@
 #define ___ASM_SPARC_IOMMU_H
 #if defined(__sparc__) && defined(__arch64__)
 #include 
-#else
-#include 
 #endif
 #endif
diff --git a/arch/sparc/include/asm/iommu_32.h 
b/arch/sparc/include/asm/iommu_32.h
deleted file mode 100644
index af51cd5ea3c1..
--- a/arch/sparc/include/asm/iommu_32.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* iommu.h: Definitions for the sun4m IOMMU.
- *
- * Copyright (C) 1996 David S. Miller (da...@caip.rutgers.edu)
- */
-#ifndef _SPARC_IOMMU_H
-#define _SPARC_IOMMU_H
-
-#include 
-#include 
-
-/* The iommu handles all virtual to physical address translations
- * that occur between the SBUS and physical memory.  Access by
- * the cpu to IO registers and similar go over the mbus so are
- * translated by the on chip SRMMU.  The iommu and the srmmu do
- * not need to have the same translations at all, in fact most
- * of the time the translations they handle are a disjunct set.
- * Basically the iommu handles all dvma sbus activity.
- */
-
-/* The IOMMU registers occupy three pages in IO space. */
-struct iommu_regs {
-   /* First page */
-   volatile unsigned long control;/* IOMMU control */
-   volatile unsigned long base;   /* Physical base of iopte page table 
*/
-   volatile unsigned long _unused1[3];
-   volatile unsigned long tlbflush;   /* write only */
-   volatile unsigned long pageflush;  /* write only */
-   volatile unsigned long _unused2[1017];
-   /* Second page */
-   volatile unsigned long afsr;   /* Async-fault status register */
-   volatile unsigned long afar;   /* Async-fault physical address */
-   volatile unsigned long _unused3[2];
-   volatile unsigned long sbuscfg0;   /* SBUS configuration registers, 
per-slot */
-   volatile unsigned long sbuscfg1;
-   volatile unsigned long sbuscfg2;
-   volatile unsigned long sbuscfg3;
-   volatile unsigned long mfsr;   /* Memory-fault status register */
-   volatile unsigned long mfar;   /* Memory-fault physical address */
-   volatile unsigned long _unused4[1014];
-   /* Third page */
-   volatile unsigned long mid;/* IOMMU module-id */
-};
-
-#define IOMMU_CTRL_IMPL 0xf000 /* Implementation */
-#define IOMMU_CTRL_VERS 0x0f00 /* Version */
-#define IOMMU_CTRL_RNGE 0x001c /* Mapping RANGE */
-#define IOMMU_RNGE_16MB 0x /* 0xff00 -> 0x */
-#define IOMMU_RNGE_32MB 0x0004 /* 0xfe00 -> 0x */
-#define IOMMU_RNGE_64MB 0x0008 /* 0xfc00 -> 0x */
-#define IOMMU_RNGE_128MB0x000c /* 0xf800 -> 0x */
-#define IOMMU_RNGE_256MB0x0010 /* 0xf000 -> 0x */
-#define IOMMU_RNGE_512MB0x0014 /* 0xe000 -> 0x */
-#define IOMMU_RNGE_1GB  0x0018 /* 0xc000 -> 0x */
-#define IOMMU_RNGE_2GB  0x001c /* 0x8000 -> 0x */
-#define IOMMU_CTRL_ENAB 0x0001 /* IOMMU Enable */
-
-#define IOMMU_AFSR_ERR  0x8000 /* LE, TO, or BE asserted */
-#define IOMMU_AFSR_LE   0x4000 /* SBUS reports error after transaction 
*/
-#define IOMMU_AFSR_TO   0x2000 /* Write access took more than 12.8 us. 
*/
-#define IOMMU_AFSR_BE   0x1000 /* Write access received error 
acknowledge */
-#define IOMMU_AFSR_SIZE 0x0e00 /* Size of transaction causing error */
-#define IOMMU_AFSR_S0x0100 /* Sparc was in supervisor mode */
-#define IOMMU_AFSR_RESV 0x00f0 /* Reserver, forced to 0x8 by hardware 
*/
-#define IOMMU_AFSR_ME   0x0008 /* Multiple errors occurred */
-#define IOMMU_AFSR_RD   0x0004 /* A read operation was in progress */
-#define IOMMU_AFSR_FAV  0x0002 /* IOMMU afar has valid contents */
-
-#define IOMMU_SBCFG_SAB30   0x0001 /* Phys-address bit 30 when bypass 
enabled */
-#define IOMMU_SBCFG_BA160x0004 /* Slave supports 16 byte bursts */
-#define IOMMU_SBCFG_BA8 0x0002 /* Slave supports 8 byte bursts */
-#define IOMMU_SBCFG_BYPASS  0x0001 /* Bypass IOMMU, treat all addresses
-  

[PATCH 15/27] sparc32: Drop check for sparc_model

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

sparc32 is always LEON, so no need to check for the model.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/cpu_type.h | 18 -
 arch/sparc/include/asm/io_32.h|  4 +-
 arch/sparc/include/asm/pgtsrmmu.h |  1 -
 arch/sparc/kernel/devices.c   |  7 +---
 arch/sparc/kernel/ioport.c|  4 +-
 arch/sparc/kernel/leon_pmc.c  | 16 
 arch/sparc/kernel/setup_32.c  | 79 +--
 7 files changed, 12 insertions(+), 117 deletions(-)

diff --git a/arch/sparc/include/asm/cpu_type.h 
b/arch/sparc/include/asm/cpu_type.h
index 2b59799859d1..3e0154c3f41d 100644
--- a/arch/sparc/include/asm/cpu_type.h
+++ b/arch/sparc/include/asm/cpu_type.h
@@ -2,28 +2,10 @@
 #ifndef __ASM_CPU_TYPE_H
 #define __ASM_CPU_TYPE_H
 
-/*
- * Sparc (general) CPU types
- */
-enum sparc_cpu {
-  sun4m   = 0x00,
-  sun4d   = 0x01,
-  sun4e   = 0x02,
-  sun4u   = 0x03, /* V8 ploos ploos */
-  sun_unknown = 0x04,
-  ap1000  = 0x05, /* almost a sun4m */
-  sparc_leon  = 0x06, /* Leon SoC */
-};
-
 #ifdef CONFIG_SPARC32
-extern enum sparc_cpu sparc_cpu_model;
 
 #define SUN4M_NCPUS4  /* Architectural limit of sun4m. 
*/
 
-#else
-
-#define sparc_cpu_model sun4u
-
 #endif
 
 #endif /* __ASM_CPU_TYPE_H */
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 549f0a72280d..83abe709d120 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -138,11 +138,11 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *);
 
 static inline int sbus_can_dma_64bit(void)
 {
-   return 0; /* actually, sparc_cpu_model==sun4d */
+   return 0;
 }
 static inline int sbus_can_burst64(void)
 {
-   return 0; /* actually, sparc_cpu_model==sun4d */
+   return 0;
 }
 struct device;
 void sbus_set_sbus64(struct device *, int);
diff --git a/arch/sparc/include/asm/pgtsrmmu.h 
b/arch/sparc/include/asm/pgtsrmmu.h
index 7cb5cbc83211..664d4bba1bcb 100644
--- a/arch/sparc/include/asm/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
@@ -124,7 +124,6 @@ static inline void srmmu_flush_whole_tlb(void)
 "i" (ASI_M_FLUSH_PROBE) : "memory");
 
 }
-
 #endif /* !(__ASSEMBLY__) */
 
 #endif /* !(_SPARC_PGTSRMMU_H) */
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index b3c2d51b22c4..2963e89611a3 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -26,8 +26,6 @@
 
 static char *cpu_mid_prop(void)
 {
-   if (sparc_cpu_model == sun4d)
-   return "cpu-id";
return "mid";
 }
 
@@ -40,8 +38,6 @@ static int check_cpu_node(phandle nd, int *cur_inst,
*prom_node = nd;
if (mid) {
*mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
-   if (sparc_cpu_model == sun4m)
-   *mid &= 3;
}
return 0;
}
@@ -92,8 +88,7 @@ static int cpu_mid_compare(phandle nd, int instance, void 
*_arg)
int this_mid;
 
this_mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
-   if (this_mid == desired_mid
-   || (sparc_cpu_model == sun4m && (this_mid & 3) == desired_mid))
+   if (this_mid == desired_mid)
return 0;
return -ENODEV;
 }
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 5ebca5c7af1e..cf0ace29704a 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -309,9 +309,7 @@ arch_initcall(sparc_register_ioport);
 void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
enum dma_data_direction dir)
 {
-   if (dir != DMA_TO_DEVICE &&
-   sparc_cpu_model == sparc_leon &&
-   !sparc_leon3_snooping_enabled())
+   if (dir != DMA_TO_DEVICE && !sparc_leon3_snooping_enabled())
leon_flush_dcache_all();
 }
 
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c
index 6c00cbad7fb5..d4a2d49f941c 100644
--- a/arch/sparc/kernel/leon_pmc.c
+++ b/arch/sparc/kernel/leon_pmc.c
@@ -79,15 +79,13 @@ static void pmc_leon_idle(void)
 /* Install LEON Power Down function */
 static int __init leon_pmc_install(void)
 {
-   if (sparc_cpu_model == sparc_leon) {
-   /* Assign power management IDLE handler */
-   if (pmc_leon_need_fixup())
-   sparc_idle = pmc_leon_idle_fixup;
-   else
-   sparc_idle = pmc_leon_idle;
-
-   printk(KERN_INFO "leon: power management initialized\n");
-   }
+   /* Assign power management IDLE handler */
+   if (pmc_leon_need_fixup())
+   sparc_idle = pmc_leon_idle_fixup;
+   else
+   sparc_idle = pmc_leon_idle;
+

[PATCH 18/27] sparc32: Drop support for 7 register windows

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Some older SPARC CPUs had support for only 7 register windows.
To support this run-time patching was used.

LEON demand 8 register windows for use with Linux so
there is no need to support the 7 window configuration.

The complexity of the assembler code is reduced
when dropping the run-time patching, thus increasing
the maintainability.

Signed-off-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/switch_to_32.h |  1 -
 arch/sparc/kernel/entry.S | 28 ---
 arch/sparc/kernel/etrap_32.S  | 35 +--
 arch/sparc/kernel/head_32.S   | 65 ---
 arch/sparc/kernel/rtrap_32.S  | 55 +
 arch/sparc/kernel/wof.S   | 43 ---
 arch/sparc/kernel/wuf.S   | 20 +++
 7 files changed, 57 insertions(+), 190 deletions(-)

diff --git a/arch/sparc/include/asm/switch_to_32.h 
b/arch/sparc/include/asm/switch_to_32.h
index 42eeafcb8a41..7aaaf31c09b4 100644
--- a/arch/sparc/include/asm/switch_to_32.h
+++ b/arch/sparc/include/asm/switch_to_32.h
@@ -37,7 +37,6 @@ extern struct thread_info *current_set[NR_CPUS];
 
 #define prepare_arch_switch(next) do { \
__asm__ __volatile__( \
-   ".globl\tflush_patch_switch\nflush_patch_switch:\n\t" \
"save %sp, -0x40, %sp; save %sp, -0x40, %sp; save %sp, -0x40, %sp\n\t" \
"save %sp, -0x40, %sp; save %sp, -0x40, %sp; save %sp, -0x40, %sp\n\t" \
"save %sp, -0x40, %sp\n\t" \
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 9cf8f87e8c42..078a8f7f8383 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -384,11 +384,8 @@ do_flush_windows:
 
RESTORE_ALL
 
-   .globl  flush_patch_one
-
/* We get these for debugging routines using __builtin_return_address() 
*/
 dfw_kernel:
-flush_patch_one:
FLUSH_ALL_KERNEL_WINDOWS
 
/* Advance over the trap instruction. */
@@ -558,10 +555,9 @@ sys_rt_sigreturn:
 * XXX code just like on sparc64... -DaveM
 */
.align  4
-   .globl  sys_fork, flush_patch_two
+   .globl  sys_fork
 sys_fork:
mov %o7, %l5
-flush_patch_two:
FLUSH_ALL_KERNEL_WINDOWS;
ld  [%curptr + TI_TASK], %o4
rd  %psr, %g4
@@ -574,10 +570,9 @@ flush_patch_two:
 mov%l5, %o7
 
/* Whee, kernel threads! */
-   .globl  sys_clone, flush_patch_three
+   .globl  sys_clone
 sys_clone:
mov %o7, %l5
-flush_patch_three:
FLUSH_ALL_KERNEL_WINDOWS;
ld  [%curptr + TI_TASK], %o4
rd  %psr, %g4
@@ -590,9 +585,8 @@ flush_patch_three:
 mov%l5, %o7
 
/* Whee, real vfork! */
-   .globl  sys_vfork, flush_patch_four
+   .globl  sys_vfork
 sys_vfork:
-flush_patch_four:
FLUSH_ALL_KERNEL_WINDOWS;
ld  [%curptr + TI_TASK], %o4
rd  %psr, %g4
@@ -909,17 +903,7 @@ breakpoint_trap:
 #endif
 
.align  4
-   .globl  flush_patch_exception
-flush_patch_exception:
-   FLUSH_ALL_KERNEL_WINDOWS;
-   ldd [%o0], %o6
-   jmpl%o7 + 0xc, %g0  ! see asm-sparc/processor.h
-mov1, %g1  ! signal EFAULT condition
-
-   .align  4
-   .globl  kill_user_windows, kuw_patch1_7win
-   .globl  kuw_patch1
-kuw_patch1_7win:   sll %o3, 6, %o3
+   .globl  kill_user_windows
 
/* No matter how much overhead this routine has in the worst
 * case scenario, it is several times better than taking the
@@ -939,11 +923,11 @@ kill_user_windows:
be  4f  ! yep, we are done
 rd %wim, %o3   ! get current wim
srl %o3, 1, %o4 ! simulate a save
-kuw_patch1:
+kuw_next:
sll %o3, 7, %o3 ! compute next wim
or  %o4, %o3, %o3   ! result
andncc  %o0, %o3, %o0   ! clean this bit in umask
-   bne kuw_patch1  ! not done yet
+   bne kuw_next! not done yet
 srl%o3, 1, %o4 ! begin another save simulation
wr  %o3, 0x0, %wim  ! set the new wim
st  %g0, [%g6 + TI_UWINMASK]! clear uwinmask
diff --git a/arch/sparc/kernel/etrap_32.S b/arch/sparc/kernel/etrap_32.S
index bb222459f097..95dfdea1f36c 100644
--- a/arch/sparc/kernel/etrap_32.S
+++ b/arch/sparc/kernel/etrap_32.S
@@ -30,18 +30,6 @@
.text
.align 4
 
-   /* SEVEN WINDOW PATCH INSTRUCTIONS */
-   .globl  tsetup_7win_patch1, tsetup_7win_patch2
-   .globl  tsetup_7win_patch3, tsetup_7win_patch4
-   .globl  tsetup_7win_patch5, tsetup_7win_patch6
-tsetup_7win_patch1: 

[PATCH 05/27] sparc32: Drop sun specific power management drivers

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the two sun specific apc and pmc drivers.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig |   7 --
 arch/sparc/kernel/Makefile |   1 -
 arch/sparc/kernel/apc.c| 196 -
 arch/sparc/kernel/pmc.c| 100 ---
 4 files changed, 304 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 1520f68e944a..55a9e67c482e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -324,13 +324,6 @@ config CMDLINE
 
  NOTE: This option WILL override the PROM bootargs setting!
 
-config SUN_PM
-   bool
-   default y if SPARC32
-   help
- Enable power management and CPU standby features on supported
- SPARC platforms.
-
 config SERIAL_CONSOLE
bool
depends on SPARC32
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 95687af45d20..ab47823f8b4e 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -84,7 +84,6 @@ obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o 
leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
 obj-y += auxio_$(BITS).o
-obj-$(CONFIG_SUN_PM)  += apc.o pmc.o
 
 obj-y += termios.o
 
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
deleted file mode 100644
index d44725d37e30..
--- a/arch/sparc/kernel/apc.c
+++ /dev/null
@@ -1,196 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* apc - Driver implementation for power management functions
- * of Aurora Personality Chip (APC) on SPARCstation-4/5 and
- * derivatives.
- *
- * Copyright (c) 2002 Eric Brower (ebro...@usa.net)
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* Debugging
- * 
- * #define APC_DEBUG_LED
- */
-
-#define APC_MINOR  MISC_DYNAMIC_MINOR
-#define APC_OBPNAME"power-management"
-#define APC_DEVNAME "apc"
-
-static u8 __iomem *regs;
-static int apc_no_idle = 0;
-
-#define apc_readb(offs)(sbus_readb(regs+offs))
-#define apc_writeb(val, offs)  (sbus_writeb(val, regs+offs))
-
-/* Specify "apc=noidle" on the kernel command line to 
- * disable APC CPU standby support.  Certain prototype
- * systems (SPARCstation-Fox) do not play well with APC
- * CPU idle, so disable this if your system has APC and 
- * crashes randomly.
- */
-static int __init apc_setup(char *str) 
-{
-   if(!strncmp(str, "noidle", strlen("noidle"))) {
-   apc_no_idle = 1;
-   return 1;
-   }
-   return 0;
-}
-__setup("apc=", apc_setup);
-
-/* 
- * CPU idle callback function
- * See .../arch/sparc/kernel/process.c
- */
-static void apc_swift_idle(void)
-{
-#ifdef APC_DEBUG_LED
-   set_auxio(0x00, AUXIO_LED); 
-#endif
-
-   apc_writeb(apc_readb(APC_IDLE_REG) | APC_IDLE_ON, APC_IDLE_REG);
-
-#ifdef APC_DEBUG_LED
-   set_auxio(AUXIO_LED, 0x00); 
-#endif
-} 
-
-static inline void apc_free(struct platform_device *op)
-{
-   of_iounmap(>resource[0], regs, resource_size(>resource[0]));
-}
-
-static int apc_open(struct inode *inode, struct file *f)
-{
-   return 0;
-}
-
-static int apc_release(struct inode *inode, struct file *f)
-{
-   return 0;
-}
-
-static long apc_ioctl(struct file *f, unsigned int cmd, unsigned long __arg)
-{
-   __u8 inarg, __user *arg = (__u8 __user *) __arg;
-
-   switch (cmd) {
-   case APCIOCGFANCTL:
-   if (put_user(apc_readb(APC_FANCTL_REG) & APC_REGMASK, arg))
-   return -EFAULT;
-   break;
-
-   case APCIOCGCPWR:
-   if (put_user(apc_readb(APC_CPOWER_REG) & APC_REGMASK, arg))
-   return -EFAULT;
-   break;
-
-   case APCIOCGBPORT:
-   if (put_user(apc_readb(APC_BPORT_REG) & APC_BPMASK, arg))
-   return -EFAULT;
-   break;
-
-   case APCIOCSFANCTL:
-   if (get_user(inarg, arg))
-   return -EFAULT;
-   apc_writeb(inarg & APC_REGMASK, APC_FANCTL_REG);
-   break;
-
-   case APCIOCSCPWR:
-   if (get_user(inarg, arg))
-   return -EFAULT;
-   apc_writeb(inarg & APC_REGMASK, APC_CPOWER_REG);
-   break;
-
-   case APCIOCSBPORT:
-   if (get_user(inarg, arg))
-   return -EFAULT;
-   apc_writeb(inarg & APC_BPMASK, APC_BPORT_REG);
-   break;
-
-   default:
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
-static const struct file_operations apc_fops = {
-   .unlocked_ioctl =   apc_ioctl,
-   .open = apc_open,
-   .release =   

[PATCH 25/27] sparc32: Drop sbus support

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

LEON do not have an sbus - so drop support for that for sparc32.
Fix a few Kconfig expressions to use CONFIG_SBUS rather than SPARC
as only SPARC64 has an sbus now.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/Kconfig   |  4 +-
 arch/sparc/include/asm/fb.h  |  8 ++--
 arch/sparc/include/asm/io_32.h   | 83 
 arch/sparc/kernel/ioport.c   | 49 
 arch/sparc/kernel/of_device_32.c | 14 ---
 drivers/video/fbdev/Kconfig  |  2 +-
 sound/sparc/Kconfig  |  1 +
 7 files changed, 9 insertions(+), 152 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 0fc52c3c7487..1b9cf7f3c500 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -392,11 +392,11 @@ endmenu
 menu "Bus options (PCI etc.)"
 config SBUS
bool
-   default y
+   default y if SPARC64
 
 config SBUSCHAR
bool
-   default y
+   default y if SPARC64
 
 config SUN_LDOMS
bool "Sun Logical Domains support"
diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
index 24440c0fda49..15b007875457 100644
--- a/arch/sparc/include/asm/fb.h
+++ b/arch/sparc/include/asm/fb.h
@@ -8,6 +8,9 @@
 
 struct fb_info;
 
+int fb_is_primary_device(struct fb_info *info);
+#define fb_is_primary_device fb_is_primary_device
+
 #ifdef CONFIG_SPARC32
 static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
  unsigned long vm_start, unsigned long 
vm_end,
@@ -18,9 +21,7 @@ static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
 #define pgprot_framebuffer pgprot_framebuffer
 #endif
 
-int fb_is_primary_device(struct fb_info *info);
-#define fb_is_primary_device fb_is_primary_device
-
+#ifdef CONFIG_SPARC64
 static inline void fb_memcpy_fromio(void *to, const volatile void __iomem 
*from, size_t n)
 {
sbus_memcpy_fromio(to, from, n);
@@ -38,6 +39,7 @@ static inline void fb_memset_io(volatile void __iomem *addr, 
int c, size_t n)
sbus_memset_io(addr, c, n);
 }
 #define fb_memset fb_memset_io
+#endif
 
 #include 
 
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 83abe709d120..b9f280ee1b11 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -56,78 +56,6 @@ static inline void _memcpy_toio(volatile void __iomem *dst, 
const void *src,
}
 }
 
-/*
- * SBus accessors.
- *
- * SBus has only one, memory mapped, I/O space.
- * We do not need to flip bytes for SBus of course.
- */
-static inline u8 sbus_readb(const volatile void __iomem *addr)
-{
-   return *(__force volatile u8 *)addr;
-}
-
-static inline u16 sbus_readw(const volatile void __iomem *addr)
-{
-   return *(__force volatile u16 *)addr;
-}
-
-static inline u32 sbus_readl(const volatile void __iomem *addr)
-{
-   return *(__force volatile u32 *)addr;
-}
-
-static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
-{
-   *(__force volatile u8 *)addr = b;
-}
-
-static inline void sbus_writew(u16 w, volatile void __iomem *addr)
-{
-   *(__force volatile u16 *)addr = w;
-}
-
-static inline void sbus_writel(u32 l, volatile void __iomem *addr)
-{
-   *(__force volatile u32 *)addr = l;
-}
-
-static inline void sbus_memset_io(volatile void __iomem *__dst, int c,
-  __kernel_size_t n)
-{
-   while(n--) {
-   sbus_writeb(c, __dst);
-   __dst++;
-   }
-}
-
-static inline void sbus_memcpy_fromio(void *dst,
-  const volatile void __iomem *src,
-  __kernel_size_t n)
-{
-   char *d = dst;
-
-   while (n--) {
-   char tmp = sbus_readb(src);
-   *d++ = tmp;
-   src++;
-   }
-}
-
-static inline void sbus_memcpy_toio(volatile void __iomem *dst,
-const void *src,
-__kernel_size_t n)
-{
-   const char *s = src;
-   volatile void __iomem *d = dst;
-
-   while (n--) {
-   char tmp = *s++;
-   sbus_writeb(tmp, d);
-   d++;
-   }
-}
-
 /* Create a virtual mapping cookie for an IO port range */
 void __iomem *ioport_map(unsigned long port, unsigned int nr);
 void ioport_unmap(void __iomem *);
@@ -136,17 +64,6 @@ void ioport_unmap(void __iomem *);
 struct pci_dev;
 void pci_iounmap(struct pci_dev *dev, void __iomem *);
 
-static inline int sbus_can_dma_64bit(void)
-{
-   return 0;
-}
-static inline int sbus_can_burst64(void)
-{
-   return 0;
-}
-struct device;
-void sbus_set_sbus64(struct device *, int);
-
 #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
 
 
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9c4c72775274..97b836f3be25 100644
--- a/arch/sparc/kernel/ioport.c
++

[PATCH 26/27] sbus: char: Drop now unused uctrl driver

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

The uctrl driver is only relevant for the Sparcbook 3 machine,
and with sun4m support removed this driver is no logner relevant.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 drivers/sbus/char/Kconfig  |   8 -
 drivers/sbus/char/Makefile |   1 -
 drivers/sbus/char/uctrl.c  | 435 -
 3 files changed, 444 deletions(-)

diff --git a/drivers/sbus/char/Kconfig b/drivers/sbus/char/Kconfig
index 7c0a308e4959..8b80abc554ed 100644
--- a/drivers/sbus/char/Kconfig
+++ b/drivers/sbus/char/Kconfig
@@ -21,14 +21,6 @@ config OBP_FLASH
  The OpenBoot PROM on Ultra systems is flashable. If you want to be
  able to upgrade the OBP firmware, say Y here.
 
-config TADPOLE_TS102_UCTRL
-   tristate "Tadpole TS102 Microcontroller support"
-   help
- Say Y here to directly support the TS102 Microcontroller interface
- on the Tadpole Sparcbook 3.  This device handles power-management
- events, and can also notice the attachment/detachment of external
- monitors and mice.
-
 config BBC_I2C
tristate "UltraSPARC-III bootbus i2c controller driver"
depends on PCI && SPARC64
diff --git a/drivers/sbus/char/Makefile b/drivers/sbus/char/Makefile
index 44347c918f6b..9db2faabfae8 100644
--- a/drivers/sbus/char/Makefile
+++ b/drivers/sbus/char/Makefile
@@ -14,6 +14,5 @@ obj-$(CONFIG_ENVCTRL) += envctrl.o
 obj-$(CONFIG_DISPLAY7SEG)  += display7seg.o
 obj-$(CONFIG_OBP_FLASH)+= flash.o
 obj-$(CONFIG_SUN_OPENPROMIO)   += openprom.o
-obj-$(CONFIG_TADPOLE_TS102_UCTRL)  += uctrl.o
 obj-$(CONFIG_BBC_I2C)  += bbc.o
 obj-$(CONFIG_ORACLE_DAX)   += oradax.o
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c
deleted file mode 100644
index 0660425e3a5a..
--- a/drivers/sbus/char/uctrl.c
+++ /dev/null
@@ -1,435 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* uctrl.c: TS102 Microcontroller interface on Tadpole Sparcbook 3
- *
- * Copyright 1999 Derrick J Brashear (sha...@dementia.org)
- * Copyright 2008 David S. Miller (da...@davemloft.net)
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#define DEBUG 1
-#ifdef DEBUG
-#define dprintk(x) printk x
-#else
-#define dprintk(x)
-#endif
-
-struct uctrl_regs {
-   u32 uctrl_intr;
-   u32 uctrl_data;
-   u32 uctrl_stat;
-   u32 uctrl_xxx[5];
-};
-
-struct ts102_regs {
-   u32 card_a_intr;
-   u32 card_a_stat;
-   u32 card_a_ctrl;
-   u32 card_a_xxx;
-   u32 card_b_intr;
-   u32 card_b_stat;
-   u32 card_b_ctrl;
-   u32 card_b_xxx;
-   u32 uctrl_intr;
-   u32 uctrl_data;
-   u32 uctrl_stat;
-   u32 uctrl_xxx;
-   u32 ts102_xxx[4];
-};
-
-/* Bits for uctrl_intr register */
-#define UCTRL_INTR_TXE_REQ 0x01/* transmit FIFO empty int req */
-#define UCTRL_INTR_TXNF_REQ0x02/* transmit FIFO not full int req */
-#define UCTRL_INTR_RXNE_REQ0x04/* receive FIFO not empty int req */
-#define UCTRL_INTR_RXO_REQ 0x08/* receive FIFO overflow int req */
-#define UCTRL_INTR_TXE_MSK 0x10/* transmit FIFO empty mask */
-#define UCTRL_INTR_TXNF_MSK0x20/* transmit FIFO not full mask */
-#define UCTRL_INTR_RXNE_MSK0x40/* receive FIFO not empty mask */
-#define UCTRL_INTR_RXO_MSK 0x80/* receive FIFO overflow mask */
-
-/* Bits for uctrl_stat register */
-#define UCTRL_STAT_TXE_STA 0x01/* transmit FIFO empty status */
-#define UCTRL_STAT_TXNF_STA0x02/* transmit FIFO not full status */
-#define UCTRL_STAT_RXNE_STA0x04/* receive FIFO not empty status */
-#define UCTRL_STAT_RXO_STA 0x08/* receive FIFO overflow status */
-
-static DEFINE_MUTEX(uctrl_mutex);
-static const char *uctrl_extstatus[16] = {
-"main power available",
-"internal battery attached",
-"external battery attached",
-"external VGA attached",
-"external keyboard attached",
-"external mouse attached",
-"lid down",
-"internal battery currently charging",
-"external battery currently charging",
-"internal battery currently discharging",
-"external battery currently discharging",
-};
-
-/* Everything required for one transaction with the uctrl */
-struct uctrl_txn {
-   u8 opcode;
-   u8 inbits;
-   u8 outbits;
-   u8 *inbuf;
-   u8 *outbuf;
-};
-
-struct uctrl_status {
-   u8 current_temp; /* 0x07 */
-   u8 reset_status; /* 0x0b */
-   u16 event_status; /* 0x0c */
-   u

[PATCH 19/27] sparc32: Drop additional sun4d bits

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop sun4d specific support. Not used by LEON.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/io-unit.h |  59 
 arch/sparc/include/asm/obio.h| 226 ---
 arch/sparc/include/asm/sbi.h | 116 
 arch/sparc/kernel/entry.S|   1 -
 arch/sparc/kernel/ioport.c   |   1 -
 arch/sparc/mm/Makefile   |   2 +-
 arch/sparc/mm/io-unit.c  | 283 ---
 arch/sparc/mm/srmmu.c|   1 -
 8 files changed, 1 insertion(+), 688 deletions(-)

diff --git a/arch/sparc/include/asm/io-unit.h b/arch/sparc/include/asm/io-unit.h
deleted file mode 100644
index 8c38f5b9f927..
--- a/arch/sparc/include/asm/io-unit.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* io-unit.h: Definitions for the sun4d IO-UNIT.
- *
- * Copyright (C) 1997,1998 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
- */
-#ifndef _SPARC_IO_UNIT_H
-#define _SPARC_IO_UNIT_H
-
-#include 
-#include 
-#include 
-
-/* The io-unit handles all virtual to physical address translations
- * that occur between the SBUS and physical memory.  Access by
- * the cpu to IO registers and similar go over the xdbus so are
- * translated by the on chip SRMMU.  The io-unit and the srmmu do
- * not need to have the same translations at all, in fact most
- * of the time the translations they handle are a disjunct set.
- * Basically the io-unit handles all dvma sbus activity.
- */
- 
-/* AIEEE, unlike the nice sun4m, these monsters have 
-   fixed DMA range 64M */
- 
-#define IOUNIT_DMA_BASE0xfc00 /* TOP - 64M */
-#define IOUNIT_DMA_SIZE0x0400 /* 64M */
-/* We use last 1M for sparc_dvma_malloc */
-#define IOUNIT_DVMA_SIZE0x0010 /* 1M */
-
-/* The format of an iopte in the external page tables */
-#define IOUPTE_PAGE  0xff00 /* Physical page number (PA[35:12])
*/
-#define IOUPTE_CACHE 0x0080 /* Cached (in Viking/MXCC) 
*/
-/* XXX Jakub, find out how to program SBUS streaming cache on XDBUS/sun4d.
- * XXX Actually, all you should need to do is find out where the registers
- * XXX are and copy over the sparc64 implementation I wrote.  There may be
- * XXX some horrible hwbugs though, so be careful.  -DaveM
- */
-#define IOUPTE_STREAM0x0040 /* Translation can use streaming cache 
*/
-#define IOUPTE_INTRA0x0008 /* SBUS direct slot->slot transfer  
*/
-#define IOUPTE_WRITE 0x0004 /* Writeable   
*/
-#define IOUPTE_VALID 0x0002 /* IOPTE is valid  
*/
-#define IOUPTE_PARITY0x0001 /* Parity is checked during DVMA   
*/
-
-struct iounit_struct {
-   unsigned long   bmap[(IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 3)) / 
sizeof(unsigned long)];
-   spinlock_t  lock;
-   iopte_t __iomem *page_table;
-   unsigned long   rotor[3];
-   unsigned long   limit[4];
-};
-
-#define IOUNIT_BMAP1_START 0x
-#define IOUNIT_BMAP1_END   (IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 1))
-#define IOUNIT_BMAP2_START IOUNIT_BMAP1_END
-#define IOUNIT_BMAP2_END   IOUNIT_BMAP2_START + (IOUNIT_DMA_SIZE >> 
(PAGE_SHIFT + 2))
-#define IOUNIT_BMAPM_START IOUNIT_BMAP2_END
-#define IOUNIT_BMAPM_END   ((IOUNIT_DMA_SIZE - IOUNIT_DVMA_SIZE) >> 
PAGE_SHIFT)
-
-#endif /* !(_SPARC_IO_UNIT_H) */
diff --git a/arch/sparc/include/asm/obio.h b/arch/sparc/include/asm/obio.h
deleted file mode 100644
index 1b151f738b00..
--- a/arch/sparc/include/asm/obio.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * obio.h:  Some useful locations in 0xF PA obio space on sun4d.
- *
- * Copyright (C) 1997 Jakub Jelinek 
- */
-
-#ifndef _SPARC_OBIO_H
-#define _SPARC_OBIO_H
-
-#include 
-
-/* This weird monster likes to use the very upper parts of
-   36bit PA for these things :) */
-   
-/* CSR space (for each XDBUS)
- *  
- *  |   0xFE  |   DEVID|| XDBUS ID |   |
- *  
- *  35  28 2720 1910 98 7 0
- */
-   
-#define CSR_BASE_ADDR  0xe000
-#define CSR_CPU_SHIFT  (32 - 4 - 5)
-#define CSR_XDBUS_SHIFT8
-
-#define CSR_BASE(cpu) (((CSR_BASE_ADDR >> CSR_CPU_SHIFT) + cpu) << 
CSR_CPU_SHIFT)
-
-/* ECSR space (not for each XDBUS)
- *  
- *  |   0xF  | DEVID[7:1] |   |
- *  
- *  35 32 3125 24   

[PATCH 16/27] sparc32: Drop use of sparc_config

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

sparc_config were used to handle the differences between the machines.
With only LEON supported sparc_config is no longer required.

Refactor the time code a litte as some parts are obsolete and other
parts are only used when SMP is not enabled.

Signed-off-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/include/asm/timer_32.h |  1 +
 arch/sparc/kernel/irq.h   | 37 +++---
 arch/sparc/kernel/irq_32.c|  3 --
 arch/sparc/kernel/leon_kernel.c   | 27 +++--
 arch/sparc/kernel/of_device_32.c  |  4 +--
 arch/sparc/kernel/time_32.c   | 64 +--
 6 files changed, 33 insertions(+), 103 deletions(-)

diff --git a/arch/sparc/include/asm/timer_32.h 
b/arch/sparc/include/asm/timer_32.h
index eecd2696922d..1cd89a99966f 100644
--- a/arch/sparc/include/asm/timer_32.h
+++ b/arch/sparc/include/asm/timer_32.h
@@ -17,6 +17,7 @@
 #include   /* For SUN4M_NCPUS */
 
 #define SBUS_CLOCK_RATE   200 /* 2MHz */
+#define LEON_CLOCK_RATE   100
 #define TIMER_VALUE_SHIFT 9
 #define TIMER_VALUE_MASK  0x3f
 #define TIMER_LIMIT_BIT   (1 << 31)  /* Bit 31 in Counter-Timer register */
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
index 0d9b740725b4..8a0b314c8299 100644
--- a/arch/sparc/kernel/irq.h
+++ b/arch/sparc/kernel/irq.h
@@ -44,38 +44,6 @@ struct sun4m_irq_global {
 extern struct sun4m_irq_percpu __iomem *sun4m_irq_percpu[SUN4M_NCPUS];
 extern struct sun4m_irq_global __iomem *sun4m_irq_global;
 
-/* The following definitions describe the individual platform features: */
-#define FEAT_L10_CLOCKSOURCE (1 << 0) /* L10 timer is used as a clocksource */
-#define FEAT_L10_CLOCKEVENT  (1 << 1) /* L10 timer is used as a clockevent */
-#define FEAT_L14_ONESHOT (1 << 2) /* L14 timer clockevent can oneshot */
-
-/*
- * Platform specific configuration
- * The individual platforms assign their platform
- * specifics in their init functions.
- */
-struct sparc_config {
-   void (*init_timers)(void);
-   unsigned int (*build_device_irq)(struct platform_device *op,
-unsigned int real_irq);
-
-   /* generic clockevent features - see FEAT_* above */
-   int features;
-
-   /* clock rate used for clock event timer */
-   int clock_rate;
-
-   /* one period for clock source timer */
-   unsigned int cs_period;
-
-   /* function to obtain offsett for cs period */
-   unsigned int (*get_cycles_offset)(void);
-
-   void (*clear_clock_irq)(void);
-   void (*load_profile_irq)(int cpu, unsigned int limit);
-};
-extern struct sparc_config sparc_config;
-
 unsigned int irq_alloc(unsigned int real_irq, unsigned int pil);
 void irq_link(unsigned int irq);
 void irq_unlink(unsigned int irq);
@@ -89,6 +57,11 @@ void sun4m_nmi(struct pt_regs *regs);
 /* sun4d_irq.c */
 void sun4d_handler_irq(unsigned int pil, struct pt_regs *regs);
 
+/* leon_kernel.c */
+void leon_clear_clock_irq(void);
+void leon_load_profile_irq(int cpu, unsigned int limit);
+u32 leon_cycles_offset(void);
+
 #ifdef CONFIG_SMP
 
 /* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index a6af08fce796..f76f57073323 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -24,9 +24,6 @@
 #include "kernel.h"
 #include "irq.h"
 
-/* platform specific irq setup */
-struct sparc_config sparc_config;
-
 unsigned long arch_local_irq_save(void)
 {
unsigned long retval;
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index ea04bad6a118..fa9cdaffdc6b 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -237,12 +237,6 @@ unsigned int leon_build_device_irq(unsigned int real_irq,
return irq;
 }
 
-static unsigned int _leon_build_device_irq(struct platform_device *op,
-  unsigned int real_irq)
-{
-   return leon_build_device_irq(real_irq, handle_simple_irq, "edge", 0);
-}
-
 void leon_update_virq_handling(unsigned int virq,
  irq_flow_handler_t flow_handler,
  const char *name, int do_ack)
@@ -258,7 +252,7 @@ void leon_update_virq_handling(unsigned int virq,
irq_set_chip_data(virq, (void *)mask);
 }
 
-static u32 leon_cycles_offset(void)
+u32 leon_cycles_offset(void)
 {
u32 rld, val, ctrl, off;
 
@@ -312,14 +306,6 @@ void __init leon_init_timers(void)
u32 config;
u32 ctrl;
 
-   sparc_config.get_cycles_offset = leon_cycles_offset;
-   sparc_config.cs_period = 100 / HZ;
-   sparc_config.features |= FEAT_L10_CLOCKSOURCE;
-
-#ifndef CONFIG_SMP
-   sparc_config.features |= FEAT_L10_CLOCKEVENT;
-#endif
-
leondebug_irq_disable = 0;
leon_debug

[PATCH 08/27] sparc32: Drop patching of interrupt vector

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Drop the sun4m specific handling and the patching that
takes place in sun4d and LEON.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/entry.S   | 98 -
 arch/sparc/kernel/kernel.h  |  1 -
 arch/sparc/kernel/leon_kernel.c | 16 ---
 arch/sparc/kernel/sun4d_irq.c   | 25 ---
 4 files changed, 140 deletions(-)

diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 7cf148a996b9..9bd3813b872d 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -79,15 +79,6 @@ bad_trap_handler:
 real_irq_entry:
SAVE_ALL
 
-#ifdef CONFIG_SMP
-   .globl  patchme_maybe_smp_msg
-
-   cmp %l7, 11
-patchme_maybe_smp_msg:
-   bgu maybe_smp4m_msg
-nop
-#endif
-
 real_irq_continue:
or  %l0, PSR_PIL, %g2
wr  %g2, 0x0, %psr
@@ -105,95 +96,6 @@ patch_handler_irq:
RESTORE_ALL
 
 #ifdef CONFIG_SMP
-   /* SMP per-cpu ticker interrupts are handled specially. */
-smp4m_ticker:
-   bne real_irq_continue+4
-or %l0, PSR_PIL, %g2
-   wr  %g2, 0x0, %psr
-   WRITE_PAUSE
-   wr  %g2, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4m_percpu_timer_interrupt
-add%sp, STACKFRAME_SZ, %o0
-   wr  %l0, PSR_ET, %psr
-   WRITE_PAUSE
-   RESTORE_ALL
-
-#define GET_PROCESSOR4M_ID(reg)\
-   rd  %tbr, %reg; \
-   srl %reg, 12, %reg; \
-   and %reg, 3, %reg;
-
-   /* Here is where we check for possible SMP IPI passed to us
-* on some level other than 15 which is the NMI and only used
-* for cross calls.  That has a separate entry point below.
-*
-* IPIs are sent on Level 12, 13 and 14. See IRQ_IPI_*.
-*/
-maybe_smp4m_msg:
-   GET_PROCESSOR4M_ID(o3)
-   sethi   %hi(sun4m_irq_percpu), %l5
-   sll %o3, 2, %o3
-   or  %l5, %lo(sun4m_irq_percpu), %o5
-   sethi   %hi(0x7000), %o2! Check all soft-IRQs
-   ld  [%o5 + %o3], %o1
-   ld  [%o1 + 0x00], %o3   ! sun4m_irq_percpu[cpu]->pending
-   andcc   %o3, %o2, %g0
-   be,asmp4m_ticker
-cmp%l7, 14
-   /* Soft-IRQ IPI */
-   st  %o2, [%o1 + 0x04]   ! 
sun4m_irq_percpu[cpu]->clear=0x7000
-   WRITE_PAUSE
-   ld  [%o1 + 0x00], %g0   ! sun4m_irq_percpu[cpu]->pending
-   WRITE_PAUSE
-   or  %l0, PSR_PIL, %l4
-   wr  %l4, 0x0, %psr
-   WRITE_PAUSE
-   wr  %l4, PSR_ET, %psr
-   WRITE_PAUSE
-   srl %o3, 28, %o2! shift for simpler checks below
-maybe_smp4m_msg_check_single:
-   andcc   %o2, 0x1, %g0
-   beq,a   maybe_smp4m_msg_check_mask
-andcc  %o2, 0x2, %g0
-   callsmp_call_function_single_interrupt
-nop
-   andcc   %o2, 0x2, %g0
-maybe_smp4m_msg_check_mask:
-   beq,a   maybe_smp4m_msg_check_resched
-andcc  %o2, 0x4, %g0
-   callsmp_call_function_interrupt
-nop
-   andcc   %o2, 0x4, %g0
-maybe_smp4m_msg_check_resched:
-   /* rescheduling is done in RESTORE_ALL regardless, but incr stats */
-   beq,a   maybe_smp4m_msg_out
-nop
-   callsmp_resched_interrupt
-nop
-maybe_smp4m_msg_out:
-   RESTORE_ALL
-
-
-   .globl  smp4d_ticker
-   /* SMP per-cpu ticker interrupts are handled specially. */
-smp4d_ticker:
-   SAVE_ALL
-   or  %l0, PSR_PIL, %g2
-   sethi   %hi(CC_ICLR), %o0
-   sethi   %hi(1 << 14), %o1
-   or  %o0, %lo(CC_ICLR), %o0
-   stha%o1, [%o0] ASI_M_MXCC   /* Clear PIL 14 in MXCC's ICLR */
-   wr  %g2, 0x0, %psr
-   WRITE_PAUSE
-   wr  %g2, PSR_ET, %psr
-   WRITE_PAUSE
-   callsmp4d_percpu_timer_interrupt
-add%sp, STACKFRAME_SZ, %o0
-   wr  %l0, PSR_ET, %psr
-   WRITE_PAUSE
-   RESTORE_ALL
-
.globl  smpleon_ipi
.extern leon_ipi_interrupt
/* SMP per-cpu IPI interrupts are handled specially. */
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 1d3980ac0658..85a3c3d1195e 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -145,7 +145,6 @@ extern char cputypval[];
 extern unsigned long lvl14_save[4];
 extern unsigned int real_irq_entry[];
 extern unsigned int smp4d_ticker[];
-extern unsigned int patchme_maybe_smp_msg[];
 
 /* trampoline_32.S */
 extern unsigned long sun4m_cpu_startup;
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index 4c61da491fee..ea04bad6a118 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -421,22 +421,6 @@ void __init leon_init_timers(void)
if (eirq != 0)
leon_eirq_setup(eirq);
 
-#ifdef CONFIG_SMP
-   {
- 

[PATCH 02/27] sparc32: Drop sun4m/sun4d support from head_32.S

2023-12-19 Thread Sam Ravnborg via B4 Relay
From: Sam Ravnborg 

Remove the most obvious parts of sun4* support from head_32.S.
Use a single print if a sun4* machine is detected thus restricting
boots to LEON machines.

Signed-off-by: Sam Ravnborg 
Cc: "David S. Miller" 
Cc: Arnd Bergmann 
Cc: Andreas Larsson 
---
 arch/sparc/kernel/head_32.S | 190 +++-
 1 file changed, 9 insertions(+), 181 deletions(-)

diff --git a/arch/sparc/kernel/head_32.S b/arch/sparc/kernel/head_32.S
index 964c61b5cd03..03dc232dd235 100644
--- a/arch/sparc/kernel/head_32.S
+++ b/arch/sparc/kernel/head_32.S
@@ -45,11 +45,7 @@ cputypvar:
.align 4
 
 notsup:
-   .asciz  "Sparc-Linux sun4/sun4c or MMU-less not supported\n\n"
-   .align 4
-
-sun4e_notsup:
-.asciz  "Sparc-Linux sun4e support does not exist\n\n"
+   .asciz  "This kernel only supports LEON SPARC V8\n\n"
.align 4
 
 /* The trap-table - located in the __HEAD section */
@@ -215,114 +211,10 @@ not_a_sun4:
be  leon_remap  /* It is a LEON - jump */
 nop
 
-   /* Sanity-check, is MMU enabled */
-   lda [%g0] ASI_M_MMUREGS, %g1
-   andcc   %g1, 1, %g0
-   be  halt_notsup
-nop
-
-   /* Check for a viking (TI) module. */
-   cmp %g3, PSR_IMPL_TI
-   bne srmmu_not_viking
-nop
-
-   /* Figure out what kind of viking we are on.
-* We need to know if we have to play with the
-* AC bit and disable traps or not.
-*/
-
-   /* I've only seen MicroSparc's on SparcClassics with this
-* bit set.
-*/
-   set 0x800, %g2
-   lda [%g0] ASI_M_MMUREGS, %g3! peek in the control 
reg
-   and %g2, %g3, %g3
-   subcc   %g3, 0x0, %g0
-   bnz srmmu_not_viking! is in mbus 
mode
-nop
-
-   rd  %psr, %g3   ! DO NOT TOUCH %g3
-   andn%g3, PSR_ET, %g2
-   wr  %g2, 0x0, %psr
-   WRITE_PAUSE
-
-   /* Get context table pointer, then convert to
-* a physical address, which is 36 bits.
-*/
-   set AC_M_CTPR, %g4
-   lda [%g4] ASI_M_MMUREGS, %g4
-   sll %g4, 0x4, %g4   ! We use this below
-   ! DO NOT TOUCH %g4
-
-   /* Set the AC bit in the Viking's MMU control reg. */
-   lda [%g0] ASI_M_MMUREGS, %g5! DO NOT TOUCH %g5
-   set 0x8000, %g6 ! AC bit mask
-   or  %g5, %g6, %g6   ! Or it in...
-   sta %g6, [%g0] ASI_M_MMUREGS! Close your eyes...
-
-   /* Grrr, why does it seem like every other load/store
-* on the sun4m is in some ASI space...
-* Fine with me, let's get the pointer to the level 1
-* page table directory and fetch its entry.
-*/
-   lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
-   srl %o1, 0x4, %o1   ! Clear low 4 bits
-   sll %o1, 0x8, %o1   ! Make physical
-
-   /* Ok, pull in the PTD. */
-   lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB 
pgd
-
-   /* Calculate to KERNBASE entry. */
-   add %o1, KERNBASE >> (PGDIR_SHIFT - 2), %o3
-
-   /* Poke the entry into the calculated address. */
-   sta %o2, [%o3] ASI_M_BYPASS
-
-   /* I don't get it Sun, if you engineered all these
-* boot loaders and the PROM (thank you for the debugging
-* features btw) why did you not have them load kernel
-* images up in high address space, since this is necessary
-* for ABI compliance anyways?  Does this low-mapping provide
-* enhanced interoperability?
-*
-* "The PROM is the computer."
-*/
-
-   /* Ok, restore the MMU control register we saved in %g5 */
-   sta %g5, [%g0] ASI_M_MMUREGS! POW... ouch
-
-   /* Turn traps back on.  We saved it in %g3 earlier. */
-   wr  %g3, 0x0, %psr  ! tick tock, tick tock
-
-   /* Now we burn precious CPU cycles due to bad engineering. */
-   WRITE_PAUSE
-
-   /* Wow, all that just to move a 32-bit value from one
-* place to another...  Jump to high memory.
-*/
-   

Re: [PATCH 09/22] [v2] arch: fix asm-offsets.c building with -Wmissing-prototypes

2023-11-08 Thread Sam Ravnborg
On Wed, Nov 08, 2023 at 01:58:30PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> When -Wmissing-prototypes is enabled, the some asm-offsets.c files fail
> to build, even when this warning is disabled in the Makefile for normal
> files:
> 
> arch/sparc/kernel/asm-offsets.c:22:5: error: no previous prototype for 
> 'sparc32_foo' [-Werror=missing-prototypes]
> arch/sparc/kernel/asm-offsets.c:48:5: error: no previous prototype for 'foo' 
> [-Werror=missing-prototypes]
> 
> Address this by making use of the same trick as x86, marking these
> functions as 'static __used' to avoid the need for a prototype
> by not drop them in dead-code elimination.
> 
> Suggested-by: Masahiro Yamada 
> Link: 
> https://lore.kernel.org/lkml/cak7lnarfemfk0du4hed19ex_g6tuc5wg0zp+l1ayvdpof4y...@mail.gmail.com/
> Signed-off-by: Arnd Bergmann 
Looks good. I sometimes looks at sparc patches so I looked at this one.
Reviewed-by: Sam Ravnborg 


Re: [PATCH] drm/bridge: tc358767: Support input format negotiation hook

2023-11-07 Thread Sam Ravnborg
Hi Aradhya,

On Tue, Nov 07, 2023 at 01:17:03AM +0530, Aradhya Bhatia wrote:
> Hi Sam,
> 
> Thank you for the suggestion!
> 
> On 06-Nov-23 18:08, Sam Ravnborg wrote:
> > Hi Aradhya,
> > 
> > On Tue, Oct 31, 2023 at 12:58:46AM +0530, Aradhya Bhatia wrote:
> >> With new connector model, tc358767 will not create the connector, when
> >> DRM_BRIDGE_ATTACH_NO_CONNECTOR is set and display-controller driver will
> >> rely on format negotiation to setup the encoder format.
> >>
> >> Add the missing input-format negotiation hook in the
> >> drm_bridge_funcs to complete DRM_BRIDGE_ATTACH_NO_CONNECTOR support.
> >>
> >> Input format is selected to MEDIA_BUS_FMT_RGB888_1X24 as default, as is
> >> the case with older model.
> >>
> >> Reported-by: Jan Kiszka 
> >> Signed-off-by: Aradhya Bhatia 
> >> ---
> >>
> >> Notes:
> >>
> >>   * Since I do not have hardware with me, this was just build tested. I 
> >> would
> >> appreciate it if someone could test and review it, especically 
> >> somebody, who
> >> uses the bridge for DPI/DSI to eDP format conversion.
> >>
> >>   * The Toshiba TC358767 bridge is not enabled in arm64 defconfig by 
> >> default,
> >> when it should be. Hence, I sent a quick patch[0] earlier.
> >>
> >> [0]: https://lore.kernel.org/all/20231030152834.18450-1-a-bhat...@ti.com/
> >>
> >>  drivers/gpu/drm/bridge/tc358767.c | 25 +
> >>  1 file changed, 25 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/bridge/tc358767.c 
> >> b/drivers/gpu/drm/bridge/tc358767.c
> >> index ef2e373606ba..0affcefdeb1c 100644
> >> --- a/drivers/gpu/drm/bridge/tc358767.c
> >> +++ b/drivers/gpu/drm/bridge/tc358767.c
> >> @@ -1751,6 +1751,30 @@ tc_dpi_atomic_get_input_bus_fmts(struct drm_bridge 
> >> *bridge,
> >>return input_fmts;
> >>  }
> >>  
> >> +static u32 *
> >> +tc_edp_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
> >> +   struct drm_bridge_state *bridge_state,
> >> +   struct drm_crtc_state *crtc_state,
> >> +   struct drm_connector_state *conn_state,
> >> +   u32 output_fmt,
> >> +   unsigned int *num_input_fmts)
> >> +{
> >> +  u32 *input_fmts;
> >> +
> >> +  *num_input_fmts = 0;
> >> +
> >> +  input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
> >> +   GFP_KERNEL);
> >> +  if (!input_fmts)
> >> +  return NULL;
> >> +
> >> +  /* This is the DSI/DPI-end bus format */
> >> +  input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
> >> +  *num_input_fmts = 1;
> >> +
> >> +  return input_fmts;
> >> +}
> > 
> > You could benefit from using the helper:
> > drm_atomic_helper_bridge_propagate_bus_fmt()
> 
> You are right!
> 
> Upon taking a second look, I realize that the bridge chain works with
> MEDIA_BUS_FMT_FIXED bus format, when tc358767 is being used in DPI/DSI
> to eDP mode (because the panel-bridge does not have a get_output_bus_fmt
> hook, and uses the same helper for its get_input_bus_fmt hook). My patch
> creates a deviation from that, by forcing MEDIA_BUS_FMT_RGB888_1X24 even
> when eDP is involved.
> 
> Using the helper here, will certainly address this deviation.
> 
> However, for the DPI/DSI to DP mode, MEDIA_BUS_FMT_RGB888_1X24 bus
> format is required, and *just* using the helper as its get_input_bus_fmt
> hook, might not be enough.
> 
> Since tc358767 is the last bridge in DPI/DSI to DP mode, the
> output_fmt parameter get defaulted to MEDIA_BUS_FMT_FIXED too, as there
> is no get_output_bus_fmt hook present in the driver. If we simply us
> the helper here, the input_fmt will also get set to MEDIA_BUS_FMT_FIXED.
> This too is an unwanted deviation.
> 
> It seems like the right way to address both the cases, would be by
> adding the get_output_bus_fmt hook that sets output_fmt to
> MEDIA_BUS_FMT_RGB888_1X24, as well as using the helper as the
> get_input_bus_fmt hook.
> 
> If this seems good to you too, I will send a new version of Tomi's
> series[0] which incorporates this patch.

I never managed to fully wrap my head around the bus fmt negotiation,
and as I am trying to recover from a flu this is not the time to try.
Your explanations sounds like you have grasped it so I suggest to move
ahead.

Sam


Re: [PATCH] drm/bridge: tc358767: Support input format negotiation hook

2023-11-06 Thread Sam Ravnborg
Hi Aradhya,

On Tue, Oct 31, 2023 at 12:58:46AM +0530, Aradhya Bhatia wrote:
> With new connector model, tc358767 will not create the connector, when
> DRM_BRIDGE_ATTACH_NO_CONNECTOR is set and display-controller driver will
> rely on format negotiation to setup the encoder format.
> 
> Add the missing input-format negotiation hook in the
> drm_bridge_funcs to complete DRM_BRIDGE_ATTACH_NO_CONNECTOR support.
> 
> Input format is selected to MEDIA_BUS_FMT_RGB888_1X24 as default, as is
> the case with older model.
> 
> Reported-by: Jan Kiszka 
> Signed-off-by: Aradhya Bhatia 
> ---
> 
> Notes:
> 
>   * Since I do not have hardware with me, this was just build tested. I would
> appreciate it if someone could test and review it, especically somebody, 
> who
> uses the bridge for DPI/DSI to eDP format conversion.
> 
>   * The Toshiba TC358767 bridge is not enabled in arm64 defconfig by default,
> when it should be. Hence, I sent a quick patch[0] earlier.
> 
> [0]: https://lore.kernel.org/all/20231030152834.18450-1-a-bhat...@ti.com/
> 
>  drivers/gpu/drm/bridge/tc358767.c | 25 +
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358767.c 
> b/drivers/gpu/drm/bridge/tc358767.c
> index ef2e373606ba..0affcefdeb1c 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1751,6 +1751,30 @@ tc_dpi_atomic_get_input_bus_fmts(struct drm_bridge 
> *bridge,
>   return input_fmts;
>  }
>  
> +static u32 *
> +tc_edp_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
> +  struct drm_bridge_state *bridge_state,
> +  struct drm_crtc_state *crtc_state,
> +  struct drm_connector_state *conn_state,
> +  u32 output_fmt,
> +  unsigned int *num_input_fmts)
> +{
> + u32 *input_fmts;
> +
> + *num_input_fmts = 0;
> +
> + input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
> +  GFP_KERNEL);
> + if (!input_fmts)
> + return NULL;
> +
> + /* This is the DSI/DPI-end bus format */
> + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
> + *num_input_fmts = 1;
> +
> + return input_fmts;
> +}

You could benefit from using the helper:
drm_atomic_helper_bridge_propagate_bus_fmt()

Sam


Re: [PATCH 11/11] drm/bridge: tc358768: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support

2023-08-14 Thread Sam Ravnborg
Hi Tomi,

> From c13c691bd8826b978325575be9a87f577b83b86b Mon Sep 17 00:00:00 2001
> From: Tomi Valkeinen 
> Date: Mon, 14 Aug 2023 13:02:23 +0300
> Subject: [PATCH] drm/bridge: tc358768: fix 'Add DRM_BRIDGE_ATTACH_NO_CONNECTOR
>  support'
> 
> Signed-off-by: Tomi Valkeinen 
> ---
>  drivers/gpu/drm/bridge/tc358768.c | 56 +--
>  1 file changed, 24 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358768.c 
> b/drivers/gpu/drm/bridge/tc358768.c
> index 82ea4d9a814a..9705ce1bd028 100644
> --- a/drivers/gpu/drm/bridge/tc358768.c
> +++ b/drivers/gpu/drm/bridge/tc358768.c
> @@ -455,8 +455,6 @@ static int tc358768_dsi_host_detach(struct mipi_dsi_host 
> *host,
>   struct tc358768_priv *priv = dsi_host_to_tc358768(host);
>  
>   drm_bridge_remove(>bridge);
> - if (priv->output.panel)
> - drm_panel_bridge_remove(priv->output.next_bridge);
>  
>   return 0;
>  }
> @@ -531,49 +529,42 @@ static int tc358768_bridge_attach(struct drm_bridge 
> *bridge,
> enum drm_bridge_attach_flags flags)
>  {
>   struct tc358768_priv *priv = bridge_to_tc358768(bridge);
> + struct drm_bridge *next_bridge;
> + struct drm_panel *panel;
> + int ret;
>  
>   if (!drm_core_check_feature(bridge->dev, DRIVER_ATOMIC)) {
>   dev_err(priv->dev, "needs atomic updates support\n");
>   return -ENOTSUPP;
>   }
>  
> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> - struct device_node *node;
> -
> - /* Get the next bridge, connected to port@1. */
> - node = of_graph_get_remote_node(priv->dev->of_node, 1, -1);
> - if (!node)
> - return -ENODEV;
> -
> - priv->output.next_bridge = of_drm_find_bridge(node);
> - of_node_put(node);
> - if (!priv->output.next_bridge)
> - return -EPROBE_DEFER;
> - } else {
> - struct drm_bridge *bridge;
> - struct drm_panel *panel;
> - int ret;
> -
> - ret = drm_of_find_panel_or_bridge(priv->dev->of_node, 1, 0,
> -   , );
> - if (ret)
> - return ret;
> -
> - if (panel) {
> - bridge = drm_panel_bridge_add_typed(panel,
> - DRM_MODE_CONNECTOR_DSI);
> - if (IS_ERR(bridge))
> - return PTR_ERR(bridge);
> - }
> + ret = drm_of_find_panel_or_bridge(priv->dev->of_node, 1, -1, ,
> +   _bridge);

I think the right way is to wrap the panel in a bridge,
so something like:

next_bridge = devm_drm_of_get_bridge(dev, priv->dev->of_node, 1, -1)

if (IS_ERR(next_bridge))
return ...
priv->output.next_bridge = next_bridge;


Sam


> + if (ret)
> + return ret;
>  
> - priv->output.next_bridge = bridge;
> - priv->output.panel = panel;
> + if (panel) {
> + next_bridge = drm_panel_bridge_add_typed(panel,
> + DRM_MODE_CONNECTOR_DSI);
> + if (IS_ERR(next_bridge))
> + return PTR_ERR(next_bridge);
>   }
>  
> + priv->output.next_bridge = next_bridge;
> + priv->output.panel = panel;
> +
>   return drm_bridge_attach(bridge->encoder, priv->output.next_bridge, 
> bridge,
>flags);
>  }
>  
> +void tc358768_bridge_detach(struct drm_bridge *bridge)
> +{
> + struct tc358768_priv *priv = bridge_to_tc358768(bridge);
> +
> + if (priv->output.panel)
> + drm_panel_bridge_remove(priv->output.next_bridge);
> +}
> +
>  static enum drm_mode_status
>  tc358768_bridge_mode_valid(struct drm_bridge *bridge,
>  const struct drm_display_info *info,
> @@ -1156,6 +1147,7 @@ tc358768_atomic_get_input_bus_fmts(struct drm_bridge 
> *bridge,
>  
>  static const struct drm_bridge_funcs tc358768_bridge_funcs = {
>   .attach = tc358768_bridge_attach,
> + .detach = tc358768_bridge_detach,
>   .mode_valid = tc358768_bridge_mode_valid,
>   .pre_enable = tc358768_bridge_pre_enable,
>   .enable = tc358768_bridge_enable,
> -- 
> 2.34.1
> 



Re: [PATCH] drm: atmel-hlcdc: Support inverting the pixel clock polarity

2023-08-10 Thread Sam Ravnborg
> I queued it to drm-misc-next this morning.

Thanks Boris!

Sam


Re: [PATCH 00/11] fbdev/sbus: Initializers for struct fb_ops

2023-08-07 Thread Sam Ravnborg
Hi Thomas,

On Sun, Aug 06, 2023 at 01:58:51PM +0200, Thomas Zimmermann wrote:
> Add initializer macros for struct fb_ops of drivers that operate
> on SBUS-based framebuffers. Also add a Kconfig token to select the
> correct dependencies.
> 
> All drivers for SBUS-based framebuffers use the regular helpers
> for framebuffers in I/O memory (fb_io_*() and cfb_*()). Each driver
> provides its own implementation of mmap and ioctls around common
> helpers from sbuslib.o. Patches 1 to 3 clean up the code a bit and
> add a initializer macros that set up struct fb_ops correctly.
> 
> Patches 4 to 11 convert the drivers. Each patch slightly renames
> the driver's mmap and ioctl functions so that it matches the name
> pattern of sbuslib.o.
> 
> Like the other fbdev initializer macros, the SBUS helpers are
> easily grep-able. In a later patch, they can be left to empty values
> if the rsp. functionality, such as file I/O or console, has been
> disabled.
> 
> There are no functional changes. The helpers set the defaults that
> the drivers already use. The fb_io_*() functions that the initializer
> macro sets are the defaults if struct fb_ops.fb_read or .fb_write are
> NULL. After all drivers have been updated to set them explicitly, the
> defaults can be dropped and the functions can be made optional.

I have looked thought it all and it looks good.
I throw it after my sparc32 build setup - also OK.

cg6 and ffb uses their own imageblit and friends, but this is nicely
handled in the patches.
I also like how you managed to handle the compat case.

All are:
Reviewed-by: Sam Ravnborg 

Sam


Re: [PATCH] drm: atmel-hlcdc: Support inverting the pixel clock polarity

2023-08-07 Thread Sam Ravnborg
Hi Miquel,

On Mon, Aug 07, 2023 at 11:12:46AM +0200, Miquel Raynal wrote:
> Hi Sam,
> 
> s...@ravnborg.org wrote on Sat, 10 Jun 2023 22:05:15 +0200:
> 
> > On Fri, Jun 09, 2023 at 04:48:43PM +0200, Miquel Raynal wrote:
> > > On the SoC host controller, the pixel clock can be:
> > > * standard: data is launched on the rising edge
> > > * inverted: data is launched on the falling edge
> > > 
> > > Some panels may need the inverted option to be used so let's support
> > > this DRM flag.
> > > 
> > > Signed-off-by: Miquel Raynal   
> > 
> > Hi Miquel,
> > 
> > the patch is:
> > Reviewed-by: Sam Ravnborg 
> > 
> > I hope someone else can pick it up and apply it to drm-misc as
> > my drm-misc setup is hopelessly outdated atm.
> 
> I haven't been noticed this patch was picked-up, is your tree still
> outdated or can you take care of it?

I am still hopelessly behind on stuff.
I copied a few people on this mail that I hope can help.

Link to the original patch:
https://lore.kernel.org/dri-devel/20230609144843.851327-1-miquel.ray...@bootlin.com/

Sam


Re: [PATCH] fbdev/ps3fb: Build without kernel device

2023-07-31 Thread Sam Ravnborg
On Mon, Jul 31, 2023 at 07:55:00PM +0200, Thomas Zimmermann wrote:
> Use fb_info() to print status message at the end of the probe function,
> which avoids decoding the devices. fb_info() works with or without an
> fbdev kernel device. Fixes the following error:
> 
> ../drivers/video/fbdev/ps3fb.c: In function 'ps3fb_probe':
> ../drivers/video/fbdev/ps3fb.c:1172:40: error: 'struct fb_info' has no member 
> named 'dev'
>  1172 |  dev_driver_string(info->dev), dev_name(info->dev),
>   |^~
> ../include/linux/dev_printk.h:110:37: note: in definition of macro 
> 'dev_printk_index_wrap'
>   110 | _p_func(dev, fmt, ##__VA_ARGS__); 
>   \
>   | ^~~
> ../drivers/video/fbdev/ps3fb.c:1171:9: note: in expansion of macro 'dev_info'
>  1171 | dev_info(info->device, "%s %s, using %u KiB of video 
> memory\n",
>   | ^~~~
> ../drivers/video/fbdev/ps3fb.c:1172:61: error: 'struct fb_info' has no member 
> named 'dev'
>  1172 |  dev_driver_string(info->dev), dev_name(info->dev),
>   | ^~
> ../include/linux/dev_printk.h:110:37: note: in definition of macro 
> 'dev_printk_index_wrap'
>   110 | _p_func(dev, fmt, ##__VA_ARGS__); 
>   \
>   | ^~~
> ../drivers/video/fbdev/ps3fb.c:1171:9: note: in expansion of macro 'dev_info'
>  1171 | dev_info(info->device, "%s %s, using %u KiB of video 
> memory\n",
>   | ^~~~
> 
> Reported-by: Randy Dunlap 
> Closes: 
> https://lore.kernel.org/lkml/ccc63065-2976-88ef-1211-731330bf2...@infradead.org/
> Signed-off-by: Thomas Zimmermann 
> Fixes: 701d2054fa31 ("fbdev: Make support for userspace interfaces 
> configurable")
> Cc: Michael Ellerman 
> Cc: Sam Ravnborg 
> Cc: Helge Deller 
> Cc: Javier Martinez Canillas 
> Cc: Randy Dunlap 
> Cc: Bagas Sanjaya 
> Cc: Thorsten Leemhuis 
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-fb...@vger.kernel.org
> Cc: linuxppc-...@lists.ozlabs.org
Acked-by: Sam Ravnborg 
> ---
>  drivers/video/fbdev/ps3fb.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
> index 5aedc30c5f7e..64d291d6b153 100644
> --- a/drivers/video/fbdev/ps3fb.c
> +++ b/drivers/video/fbdev/ps3fb.c
> @@ -1168,9 +1168,7 @@ static int ps3fb_probe(struct ps3_system_bus_device 
> *dev)
>  
>   ps3_system_bus_set_drvdata(dev, info);
>  
> - dev_info(info->device, "%s %s, using %u KiB of video memory\n",
> -  dev_driver_string(info->dev), dev_name(info->dev),
> -  info->fix.smem_len >> 10);
> + fb_info(info, "using %u KiB of video memory\n", info->fix.smem_len >> 
> 10);
>  
>   task = kthread_run(ps3fbd, info, DEVICE_NAME);
>   if (IS_ERR(task)) {
> -- 
> 2.41.0


Re: [PATCH 00/47] fbdev: Use I/O helpers

2023-07-30 Thread Sam Ravnborg
On Fri, Jul 28, 2023 at 08:35:41PM +0200, Sam Ravnborg wrote:
> Hi Thomas,
> 
> On Fri, Jul 28, 2023 at 06:39:43PM +0200, Thomas Zimmermann wrote:
> > Most fbdev drivers operate on I/O memory. And most of those use the
> > default implementations for file I/O and console drawing. Convert all
> > these low-hanging fruits to the fb_ops initializer macro and Kconfig
> > token for fbdev I/O helpers.
> > 
> > The fbdev I/O helpers are easily grep-able. In a later patch, they can
> > be left to empty values if the rsp. funtionality, such as file I/O or
> > console, has been disabled.
> > 
> > There are no functional changes. The helpers set the defaults that
> > the drivers already use.
> 
> I have browsed all patches - they all looks good.
> Reviewed-by: Sam Ravnborg 

When you post v2 with MEM added the review still holds true.

Sam


Re: [PATCH 0/4] fbdev: Rename helpers for struct fb_ops

2023-07-30 Thread Sam Ravnborg
Hi Thomas,

On Sat, Jul 29, 2023 at 09:26:45PM +0200, Thomas Zimmermann wrote:
> As discussed at [1], rename helpers for struct fb_ops to include
> 'MEM' in their name to signal that these helpers operate on a
> certain type of memory address; either I/O, system or DMA-able
> ranges. These are trival renames without any functional changes.
> 
> [1] 
> https://lore.kernel.org/dri-devel/1ab418ae-592f-4347-fa75-bf9b00115...@gmx.de/T/#mcb92691d6131333782cc83190a5fc00bd575a0c5

Yep, Helge is right that the naming is better with MEM added.
Good that we could get this sorted out now where the impact is "only" in
drm.

All 4 patches are:
Reviewed-by: Sam Ravnborg 



Re: [PATCH 00/47] fbdev: Use I/O helpers

2023-07-28 Thread Sam Ravnborg
Hi Helge,

On Fri, Jul 28, 2023 at 08:46:59PM +0200, Helge Deller wrote:
> On 7/28/23 18:39, Thomas Zimmermann wrote:
> > Most fbdev drivers operate on I/O memory.
> 
> Just nitpicking here:
> What is I/O memory?
> Isn't it either memory, or I/O ?
> I mean, I would never think of the cfb* draw functions under I/O.
> 
> > And most of those use the
> > default implementations for file I/O and console drawing. Convert all
> > these low-hanging fruits to the fb_ops initializer macro and Kconfig
> > token for fbdev I/O helpers.
> 
> I do see the motivation for your patch, but I think the
> macro names are very misleading.
> 
> You have:
> #define __FB_DEFAULT_IO_OPS_RDWR \
> .fb_read= fb_io_read, \
> .fb_write   = fb_io_write
> 
> #define __FB_DEFAULT_IO_OPS_DRAW \
> .fb_fillrect= cfb_fillrect, \
> .fb_copyarea= cfb_copyarea, \
> .fb_imageblit   = cfb_imageblit
> 
> #define __FB_DEFAULT_IO_OPS_MMAP \
> .fb_mmap= NULL /* default implementation */
> 
> #define FB_DEFAULT_IO_OPS \
> __FB_DEFAULT_IO_OPS_RDWR, \
> __FB_DEFAULT_IO_OPS_DRAW, \
> __FB_DEFAULT_IO_OPS_MMAP
> 
> I think FB_DEFAULT_IO_OPS is OK for read/write/mmap.
> But I would suggest to split out __FB_DEFAULT_IO_OPS_DRAW.
> Something like:
> #define FB_DEFAULT_IO_OPS \
> __FB_DEFAULT_IO_OPS_RDWR, \
> __FB_DEFAULT_IO_OPS_MMAP


> #define FB_DEFAULT_CFB_OPS \
> .fb_fillrect= cfb_fillrect, \
> .fb_copyarea= cfb_copyarea, \
> .fb_imageblit   = cfb_imageblit

The prefix cfb, I have recently learned, equals color frame buffer.
They are named such for purely historical reasons.

What is important is where the data are copied as we have two
implementations of for example copyarea - one using system memory, the
other using IO memory.

The naming FB_DEFAULT_IO_OPS says this is the defaults to IO memory
operations, which tell what they do and avoid the strange cfb acronym.

Reserve cfb for color frame buffers only - and maybe in the end rename
the three cfbcopyarea, cfbfillrect, cfbimgblt to use the io prefix.
Which is much simpler to do after this series - and nice extra benefit.

I hope this properly explains why I like the current naming and
acked it when the macros were introduced.

Sam


Re: [PATCH 00/47] fbdev: Use I/O helpers

2023-07-28 Thread Sam Ravnborg
Hi Thomas,

On Fri, Jul 28, 2023 at 06:39:43PM +0200, Thomas Zimmermann wrote:
> Most fbdev drivers operate on I/O memory. And most of those use the
> default implementations for file I/O and console drawing. Convert all
> these low-hanging fruits to the fb_ops initializer macro and Kconfig
> token for fbdev I/O helpers.
> 
> The fbdev I/O helpers are easily grep-able. In a later patch, they can
> be left to empty values if the rsp. funtionality, such as file I/O or
> console, has been disabled.

Did you miss sm750 or was it left out on purpose?
As it hide in staging it is easy to miss.

Sam


Re: [PATCH 00/47] fbdev: Use I/O helpers

2023-07-28 Thread Sam Ravnborg
Hi Thomas,

On Fri, Jul 28, 2023 at 06:39:43PM +0200, Thomas Zimmermann wrote:
> Most fbdev drivers operate on I/O memory. And most of those use the
> default implementations for file I/O and console drawing. Convert all
> these low-hanging fruits to the fb_ops initializer macro and Kconfig
> token for fbdev I/O helpers.
> 
> The fbdev I/O helpers are easily grep-able. In a later patch, they can
> be left to empty values if the rsp. funtionality, such as file I/O or
> console, has been disabled.
> 
> There are no functional changes. The helpers set the defaults that
> the drivers already use.

I have browsed all patches - they all looks good.
Reviewed-by: Sam Ravnborg 



Re: [PATCH] video: logo: LOGO should depend on FB_CORE i.s.o. FB

2023-07-26 Thread Sam Ravnborg
On Tue, Jul 25, 2023 at 09:53:16PM +0200, Javier Martinez Canillas wrote:
> Thomas Zimmermann  writes:
> 
> > Hi
> >
> 
> [...]
> 
> >> 
> >> Yes. I meant to move drivers/video/logo/ to drivers/fbdev/core/logo and to
> >> source its Kconfig from drivers/fbdev/core/Kconfig, since it now depends
> >> on FB_CORE.
> >
> > No, please rather leave it where it is. There's no code dependencies to 
> > the fbdev core; it merely depends on the Kconfig token.
> >
> 
> Sure, fine by me. But I disagree that there's merely a Kconfig dependency.
> The include/linux/linux_logo.h header declares both fb_find_logo() and
> fb_append_extra_logo().
> 
> The fb_find_logo() function is defined in drivers/video/logo.c while the
> fb_append_extra_logo() is in drivers/video/fbdev/core/fbmem.c, even though
> only arch/powerpc/platforms/cell/spu_base.c uses fb_append_extra_logo().
> 
> So there's a relationship already between logo and fbdev/core, that's why
> I wondered if would make sense to also move drivers/video/logo.c to have
> both functions in there.
Or as I also suggested on irc - to pull out all the logo stuff from
fbmem and put it in video/logo/
With a bit of refactoring to make it obvious this is logo stuff and
maybe avoid some of the ifdeffery in the code of the users.

Sam


Re: [PATCH] video: logo: LOGO should depend on FB_CORE i.s.o. FB

2023-07-25 Thread Sam Ravnborg
Hi Javier,

> >> >  menuconfig LOGO
> >> >   bool "Bootup logo"
> >> > - depends on FB || SGI_NEWPORT_CONSOLE
> >> > + depends on FB_CORE || SGI_NEWPORT_CONSOLE
> >> >   help
> >> > Enable and select frame buffer bootup logos.
> >>
> >> Should then move this option to drivers/video/fbdev/core/Kconfig ?
> >
> > No, all logo options are in their own file.
> >
> 
> Yes. I meant to move drivers/video/logo/ to drivers/fbdev/core/logo and to
> source its Kconfig from drivers/fbdev/core/Kconfig, since it now depends
> on FB_CORE.
> 
> But I see now that it also depends on SGI_NEWPORT_CONSOLE, so having those
> in drivers/video/logo makes sense indeed.

The SGI_NEWPORT_CONSOLE should be replaced by some ifdef in the
newport_con.c code - to do what other drivers do.
But thats for another day.

Sam


Re: [PATCH v6 1/3] drm/panel: Fix IS_ERR() vs NULL check in nt35950_probe()

2023-07-25 Thread Sam Ravnborg
On Tue, Jul 25, 2023 at 09:39:55AM +0800, Gaosheng Cui wrote:
> The mipi_dsi_device_register_full() returns an ERR_PTR() on failure,
> we should use IS_ERR() to check the return value.
> 
> By the way, use dev_err_probe instead of dev_err to print the error code.
> 
> Fixes: 623a3531e9cf ("drm/panel: Add driver for Novatek NT35950 DSI DriverIC 
> panels")
> Signed-off-by: Gaosheng Cui 

Looks good, thanks for the update.

Reviewed-by: Sam Ravnborg 


  1   2   3   4   5   6   7   8   9   10   >