linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Kern <alex.kern@gmx.de>
To: linux-fbdev-devel@lists.sourceforge.net
Cc: James Simmons <jsimmons@infradead.org>
Subject: Re: [PATCH] mach64 atari patch
Date: Mon, 8 Aug 2005 21:49:18 +0200	[thread overview]
Message-ID: <200508082149.18182.alex.kern@gmx.de> (raw)
In-Reply-To: <Pine.LNX.4.56.0508070315260.12196@pentafluge.infradead.org>

Am Sonntag, 7. August 2005 04:27 schrieb James Simmons:

As long it not breaks PCI based Mach64, I am happy
Acked-by: Alexander Kern <alex.kern@gmx.de>
> This patch makes the mach64 chip a platform device so sysfs can work with
> it.
>
> Signed-off-by: James Simmons <jsimmons@infradead.org>
>
> diff -urN -X /home/jsimmons/dontdiff
> linus-2.6/drivers/video/aty/atyfb_base.c
> fbdev-2.6/drivers/video/aty/atyfb_base.c ---
> linus-2.6/drivers/video/aty/atyfb_base.c	2005-07-11 10:07:21.000000000
> -0700 +++ fbdev-2.6/drivers/video/aty/atyfb_base.c	2005-07-27
> 08:41:24.000000000 -0700 @@ -244,9 +244,6 @@
>       */
>
>  static int aty_init(struct fb_info *info, const char *name);
> -#ifdef CONFIG_ATARI
> -static int store_video_par(char *videopar, unsigned char m64_num);
> -#endif
>
>  static struct crtc saved_crtc;
>  static union aty_pll saved_pll;
> @@ -321,10 +318,8 @@
>  #endif
>
>  #ifdef CONFIG_ATARI
> -static unsigned int mach64_count __initdata = 0;
> -static unsigned long phys_vmembase[FB_MAX] __initdata = { 0, };
> -static unsigned long phys_size[FB_MAX] __initdata = { 0, };
> -static unsigned long phys_guiregbase[FB_MAX] __initdata = { 0, };
> +static struct mach64_device* __init store_video_par(char *video_str,
> unsigned char m64_num) +static LIST_HEAD(mach64_list);
>  #endif
>
>  /* top -> down is an evolution of mach64 chipset, any corrections? */
> @@ -2170,8 +2165,6 @@
>       *  Initialisation
>       */
>
> -static struct fb_info *fb_list = NULL;
> -
>  static int __init aty_init(struct fb_info *info, const char *name)
>  {
>  	struct atyfb_par *par = (struct atyfb_par *) info->par;
> @@ -2562,8 +2555,6 @@
>  	if (register_framebuffer(info) < 0)
>  		goto aty_init_exit;
>
> -	fb_list = info;
> -
>  	PRINTKI("fb%d: %s frame buffer device on %s\n",
>  	       info->node, info->fix.id, name);
>  	return 0;
> @@ -2587,10 +2578,13 @@
>  }
>
>  #ifdef CONFIG_ATARI
> -static int __init store_video_par(char *video_str, unsigned char m64_num)
> +static struct mach64_device* __init store_video_par(char *video_str,
> unsigned char m64_num) {
> -	char *p;
>  	unsigned long vmembase, size, guiregbase;
> +	struct platform_device *atyfb_device;
> +	struct mach64_device *device;
> +	struct resource io[2];
> +	char *p;
>
>  	PRINTKI("store_video_par() '%s' \n", video_str);
>
> @@ -2604,16 +2598,18 @@
>  		goto mach64_invalid;
>  	guiregbase = simple_strtoul(p, NULL, 0);
>
> -	phys_vmembase[m64_num] = vmembase;
> -	phys_size[m64_num] = size;
> -	phys_guiregbase[m64_num] = guiregbase;
> -	PRINTKI("stored them all: $%08lX $%08lX $%08lX \n", vmembase, size,
> -	       guiregbase);
> -	return 0;
> +	io[0] = request_mem_region(vmembase, size, "atyfb");
> +	io[1] = request_mem_region(guiregbase, 0x10000, "atyfb");
>
> -      mach64_invalid:
> -	phys_vmembase[m64_num] = 0;
> -	return -1;
> +	atyfb_device = platform_device_register_simple("atyfb", m64_num, io, 2);
> +	if (IS_ERR(atyfb_device))
> +		return PTR_ERR(atyfb_device);
> +
> +	device = kmalloc(sizeof(struct mach64_device), GFP_KERNEL);
> +	PRINTKI("stored them all: $%08lX $%08lX $%08lX \n", vmembase, size,
> guiregbase); +	return device;
> +mach64_invalid:
> +	return NULL;
>  }
>  #endif /* CONFIG_ATARI */
>
> @@ -2679,17 +2675,10 @@
>  static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue,
>  		       const struct atyfb_par *par)
>  {
> -#ifdef CONFIG_ATARI
> -	out_8(&par->aty_cmap_regs->windex, regno);
> -	out_8(&par->aty_cmap_regs->lut, red);
> -	out_8(&par->aty_cmap_regs->lut, green);
> -	out_8(&par->aty_cmap_regs->lut, blue);
> -#else
>  	writeb(regno, &par->aty_cmap_regs->windex);
>  	writeb(red, &par->aty_cmap_regs->lut);
>  	writeb(green, &par->aty_cmap_regs->lut);
>  	writeb(blue, &par->aty_cmap_regs->lut);
> -#endif
>  }
>
>      /*
> @@ -3456,47 +3445,43 @@
>
>  #ifdef CONFIG_ATARI
>
> -static int __devinit atyfb_atari_probe(void)
> +static int __devinit atyfb_atari_probe(struct device *device)
>  {
> -	struct aty_par *par;
> +	struct platform_device *dev = to_platform_device(device);
>  	struct fb_info *info;
> -	int m64_num;
> +	struct aty_par *par;
> +	int size = 0;
>  	u32 clock_r;
>
> -	for (m64_num = 0; m64_num < mach64_count; m64_num++) {
> -		if (!phys_vmembase[m64_num] || !phys_size[m64_num] ||
> -		    !phys_guiregbase[m64_num]) {
> -		    PRINTKI("phys_*[%d] parameters not set => returning early. \n",
> m64_num); -			continue;
> -		}
> -
> -		info = framebuffer_alloc(sizeof(struct atyfb_par), NULL);
> -		if (!info) {
> -			PRINTKE("atyfb_atari_probe() can't alloc fb_info\n");
> -			return -ENOMEM;
> -		}
> -		par = info->par;
> +	info = framebuffer_alloc(sizeof(struct atyfb_par), &dev->dev);
> +	if (!info) {
> +		PRINTKE("atyfb_atari_probe() can't alloc fb_info\n");
> +		return -ENOMEM;
> +	}
> +	par = info->par;
>
> -		info->fix = atyfb_fix;
> +	info->fix = atyfb_fix;
>
> -		par->irq = (unsigned int) -1; /* something invalid */
> +	par->irq = (unsigned int) -1; /* something invalid */
>
> -		/*
> -		 *  Map the video memory (physical address given) to somewhere in the
> -		 *  kernel address space.
> -		 */
> -		info->screen_base = ioremap(phys_vmembase[m64_num], phys_size[m64_num]);
> -		info->fix.smem_start = (unsigned long)info->screen_base; /* Fake! */
> -		par->ati_regbase = ioremap(phys_guiregbase[m64_num], 0x10000) +
> -						0xFC00ul;
> -		info->fix.mmio_start = (unsigned long)par->ati_regbase; /* Fake! */
> -
> -		aty_st_le32(CLOCK_CNTL, 0x12345678, par);
> -		clock_r = aty_ld_le32(CLOCK_CNTL, par);
> -
> -		switch (clock_r & 0x003F) {
> -		case 0x12:
> -			par->clk_wr_offset = 3; /*  */
> +	/*
> +	 *  Map the video memory (physical address given) to somewhere in the
> +	 *  kernel address space.
> +	 */
> +	size = dev->resource[0].start - dev->resource[0].end;
> +	info->fix.smem_start = dev->resource[0].start;
> +	info->screen_base = ioremap(dev->resource[0], size);
> +
> +	size = 0x10000;
> +	info->fix.mmio_start = dev->resource[1].start + 0xFC00ul;
> +	par->ati_regbase = ioremap(dev->resource[1], size) + 0xFC00ul;
> +
> +	aty_st_le32(CLOCK_CNTL, 0x12345678, par);
> +	clock_r = aty_ld_le32(CLOCK_CNTL, par);
> +
> +	switch (clock_r & 0x003F) {
> +	case 0x12:
> +		par->clk_wr_offset = 3; /*  */
>  			break;
>  		case 0x34:
>  			par->clk_wr_offset = 2; /* Medusa ST-IO ISA Adapter etc. */
> @@ -3595,6 +3580,23 @@
>
>  #endif /* CONFIG_PCI */
>
> +#ifdef	CONFIG_ATARI
> +
> +static struct device_driver atyfb_driver = {
> +	.name		= "atyfb",
> +	.probe		= atyfb_atari_probe,
> +	.remove		= __devexit_p(atyfb_atari_remove),
> +}
> +
> +static void __devexit atyfb_atari_remove(struct device *dev)
> +{
> +	struct fb_info *info = dev_get_drvdata(dev);
> +
> +	atyfb_remove(info);
> +}
> +
> +#endif /* CONFIG_ATARI */
> +
>  #ifndef MODULE
>  static int __init atyfb_setup(char *options)
>  {
> @@ -3650,15 +3652,15 @@
>  		 * Why do we need this silly Mach64 argument?
>  		 * We are already here because of mach64= so its redundant.
>  		 */
> -		else if (MACH_IS_ATARI
> -			 && (!strncmp(this_opt, "Mach64:", 7))) {
> -			static unsigned char m64_num;
> -			static char mach64_str[80];
> +		else if (MACH_IS_ATARI && (!strncmp(this_opt, "Mach64:", 7))) {
> +			struct mach64_device *dev;
> +			unsigned char m64_num = 0;
> +			char mach64_str[80];
> +
>  			strlcpy(mach64_str, this_opt + 7, sizeof(mach64_str));
> -			if (!store_video_par(mach64_str, m64_num)) {
> -				m64_num++;
> -				mach64_count = m64_num;
> -			}
> +			dev = store_video_par(mach64_str, m64_num++);
> +			if (dev != null)
> +				list_add_tail(dev->node, &mach64_list);
>  		}
>  #endif
>  		else
> @@ -3670,6 +3672,8 @@
>
>  static int __init atyfb_init(void)
>  {
> +    int retval = 0;
> +
>  #ifndef MODULE
>      char *option = NULL;
>
> @@ -3679,16 +3683,34 @@
>  #endif
>
>  #ifdef CONFIG_PCI
> -    pci_register_driver(&atyfb_driver);
> +    retval = pci_register_driver(&atyfb_driver);
>  #endif
>  #ifdef CONFIG_ATARI
> -    atyfb_atari_probe();
> +    retval = driver_register(&atyfb_driver);
> +    if (retval < 0) {
> +	struct platform_device *device;
> +
> +	list_for_each_safe(device, &mach64_list, node) {
> +		platform_device_unregister(&device->dev);
> +		kfree(device);
> +	}
> +    }
>  #endif
> -    return 0;
> +    return retval;
>  }
>
>  static void __exit atyfb_exit(void)
>  {
> +#ifdef CONFIG_ATARI
> +	struct platform_device *device;
> +
> +	list_for_each_safe(device, &mach64_list, node) {
> +		platform_device_unregister(&device->dev);
> +		kfree(device);
> +	}
> +	driver_unregister(&atyfb_driver);
> +#endif
> +
>  #ifdef CONFIG_PCI
>  	pci_unregister_driver(&atyfb_driver);
>  #endif
> diff -urN -X /home/jsimmons/dontdiff linus-2.6/drivers/video/aty/atyfb.h
> fbdev-2.6/drivers/video/aty/atyfb.h ---
> linus-2.6/drivers/video/aty/atyfb.h	2005-07-11 10:07:21.000000000 -0700 +++
> fbdev-2.6/drivers/video/aty/atyfb.h	2005-07-22 15:36:41.000000000 -0700 @@
> -187,6 +187,13 @@
>  #endif
>  };
>
> +#ifdef CONFIG_ATARI
> +struct mach64_device {
> +	struct list_head node;
> +	struct platform_device *dev;
> +};
> +#endif
> +
>      /*
>       *  ATI Mach64 features
>       */
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Linux-fbdev-devel mailing list
> Linux-fbdev-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

-- 

Best Wishes
Mit freundlichen Grüßen

Alex Kern


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf

      parent reply	other threads:[~2005-08-09 17:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-07  2:27 [PATCH] mach64 atari patch James Simmons
2005-08-07 11:39 ` Geert Uytterhoeven
2005-08-07 16:46   ` Andrew Morton
2005-08-07 23:09     ` James Simmons
2005-08-07 23:31       ` Antonino A. Daplas
2005-08-07 23:48         ` Jon Smirl
2005-08-08 17:30           ` James Simmons
2005-08-08 17:56             ` Jon Smirl
2005-08-08 18:15               ` James Simmons
2005-08-08 18:34                 ` Jon Smirl
2005-08-08 18:44                   ` James Simmons
2005-08-08 19:01                     ` Jon Smirl
2005-08-08 19:07                       ` Jon Smirl
2005-08-08 23:55                 ` Antonino A. Daplas
2005-08-09  0:04         ` James Simmons
2005-08-09  0:59           ` Antonino A. Daplas
2005-08-09  1:08             ` Antonino A. Daplas
2005-08-09  8:05             ` Geert Uytterhoeven
2005-08-09  1:04           ` Jon Smirl
2005-08-12 17:47   ` James Simmons
2005-08-08 19:49 ` Alexander Kern [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200508082149.18182.alex.kern@gmx.de \
    --to=alex.kern@gmx.de \
    --cc=jsimmons@infradead.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).