am200epd, pxafb, metronomefb changes v5
cover am200epd, pxafb, metronomefb changes v5
Hi Eric, arm and fbdev friends,
This is version 5 of this RFC and contains the following updates:
- fix unnecessary error assignment
- get rid of unnecessary ifdef's in gpio init
- remove incorrect clk32K disable
- add warning if clk32K is not enabled by bootloader
- combine the move of am200epd to mach-pxa with the conversion to new code
- get rid of use of direct setting of LCCR
- get rid of set_irq_type
- get rid of RTSL
- rebase code to using .26rc9 + linux-2.6-arm.git/pxa
Thanks to Krzysztof and Eric for feedback.
This RFC consists of patches intended to improve the condition of the am200epd devkit support. The am200epd devkit contains a gumstix (pxa255) and a carrier board (am200epd or Lyre), and a metronome display controller. Previously, there was a drivers/video/am200epd driver that manipulated pxa LCDC registers and GPSR/GPLR registers directly. That was clearly wrong and broken so I have removed it and written a new mach-pxa am200epd support driver.This driver interfaces with pxafb through a set of callbacks to share/unshare pxafb's framebuffer and achieves the same functionality without manipulating any pxa registers directly. The patches are split as follows:
pxafb: add shared framebuffer interface
gumstix: conversion to MFP support and add bluetooth support
am200epd: convert to shared fb and use gpio api
metronomefb: convert printk to dev_dbg/err messages
metronomefb: changes to use separate framebuffer
I would be grateful for any feedback and advice.
Thanks,
jaya
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
RFC 1/5 pxafb: add shared framebuffer interface
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry in pxafb_mach_info so that a driver can pass in the correct struct device owner for the LCDCLK.
- adding custom_xfer_div entry so that a driver can have custom sized transfers. For example, the metronome controller uses 16 bit AMLCD transfers but actually has 3 bit pixels in 8 bit containers.
- adding extra_video_mem entry so that a driver can tell pxafb of its additional needs.
- adding share_video_mem/unshare_video_mem callbacks to notify the secondary driver of the framebuffer address, to allow refcounting, and to cleanup on completion.
--- arch/arm/mach-pxa/devices.c | 2 + drivers/video/pxafb.c | 48 +++++++++++++++++++++++++++++++------ include/asm-arm/arch-pxa/pxafb.h | 9 +++++++ 3 files changed, 51 insertions(+), 8 deletions(-)
arch/arm/mach-pxa/devices.c +2 -0
@@ -146,6 +146,8 @@ struct platform_device pxa_device_fb = {void __init set_pxa_fb_info (struct pxafb_mach_info *info) { +if (!info->clkdev) + info->clkdev = &pxa_device_fb.dev;pxa_register_device (&pxa_device_fb, info); }
drivers/video/pxafb.c +40 -8
142 lines not on this page · raw message
include/asm-arm/arch-pxa/pxafb.h +9 -0
@@ -139,9 +139,18 @@ struct pxafb_mach_info {* All other bits in LCCR4 should be left alone. */ u_int lccr4; +unsigned int custom_xfer_div;/* divides the pixel transfer */ +/* size of extra mem needed for secondary driver */ +unsigned int extra_video_mem; +void *extra_data;/* extra data for secondary */ void (*pxafb_backlight_power)(int );void (*pxafb_lcd_power)(int ,struct fb_var_screeninfo *);void (*smart_update)(struct fb_info *); +/* share_video_mem allows client drivers to get our framebuffer */ +int (*share_video_mem)(char __iomem *,dma_addr_t ,struct module *, +void *); +void (*unshare_video_mem)(void *); +struct device *clkdev; };void set_pxa_fb_info (struct pxafb_mach_info *hard_pxa_fb_info);void set_pxa_fb_parent (struct device *parent_dev);
Signature · 8 lines
1.5.3.6 ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.
Is it possible that LCDCLK being requested by device other than pxa_device_fb?? Could you give an example and we may work out a better solution.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 10 lines · eric miao
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.Is it possible that LCDCLK being requested by device other than
pxa_device_fb?? Could you give an example and we may work out a better solution.
Hi Eric,
You're right. I think LCDCLK is only ever requested by pxa_device_fb.
I see now that instead of doing:
- fbi->clk = clk_get(dev, "LCDCLK");
+ fbi->clk = clk_get(inf->clkdev, "LCDCLK");
a better solution would be to directly use pxa_device_fb:
- fbi->clk = clk_get(dev, "LCDCLK");
+ fbi->clk = clk_get(pxa_device_fb.dev, "LCDCLK");
and then I can avoid doing the clkdev ugliness.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 24 lines · Jaya Kumar
Quoted 10 lines · eric miao
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.Is it possible that LCDCLK being requested by device other than
pxa_device_fb?? Could you give an example and we may work out a better solution.Hi Eric,
You're right. I think LCDCLK is only ever requested by
pxa_device_fb.I see now that instead of doing:
drivers/video/pxafb.c +1
-1- fbi->clk =clk_get (dev,"LCDCLK" ); + fbi->clk =clk_get (inf->clkdev,"LCDCLK" );a better solution would be to directly use
pxa_device_fb:(quoted diff) +1
-1- fbi->clk = clk_get(dev, "LCDCLK"); + fbi->clk = clk_get(pxa_device_fb.dev, "LCDCLK");
Quoted 2 lines
and then I can avoid doing the clkdev ugliness.
Mmm... but is there any case that (dev != pxa_device_fb.dev) ??
Quoted 3 lines
Thanks,
jaya
Signature · 8 lines
Cheers - eric ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 21 lines · eric miao
Quoted 20 lines · Jaya Kumar
Quoted 10 lines · eric miao
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.Is it possible that LCDCLK being requested by device other than
pxa_device_fb?? Could you give an example and we may work out a better solution.Hi Eric,
You're right. I think LCDCLK is only ever requested by
pxa_device_fb.I see now that instead of doing:
drivers/video/pxafb.c +1
-1- fbi->clk =clk_get (dev,"LCDCLK" ); + fbi->clk =clk_get (inf->clkdev,"LCDCLK" );
Quoted 9 lines
Quoted 6 lines
a better solution would be to directly use
pxa_device_fb:(quoted diff) +1
-1- fbi->clk = clk_get(dev, "LCDCLK"); + fbi->clk = clk_get(pxa_device_fb.dev, "LCDCLK");and then I can avoid doing the clkdev ugliness.
Mmm... but is there any case that (dev != pxa_device_fb.dev) ??
Yes. In this case, am200epd because it has a different platform_device. This is because am200epd doesn't call set_pxa_fb_info so that it can be unloaded.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
In reply to Jaya KumarQuoted 21 lines · Jaya Kumar
Quoted 9 lines · eric miao
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.Is it possible that LCDCLK being requested by device other than
pxa_device_fb?? Could you give an example and we may work out a better solution.You're right. I think LCDCLK is only ever requested by
pxa_device_fb.I see now that instead of doing:
drivers/video/pxafb.c +1
-1- fbi->clk =clk_get (dev,"LCDCLK" ); + fbi->clk =clk_get (inf->clkdev,"LCDCLK" );a better solution would be to directly use
pxa_device_fb:(quoted diff) +1
-1- fbi->clk = clk_get(dev, "LCDCLK"); + fbi->clk = clk_get(pxa_device_fb.dev, "LCDCLK");
Quoted 1 line
and then I can avoid doing the clkdev ugliness.
PXA devices (intentionally) aren't exported. Nor are they going to be, so the above will fail if built as a module.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 18 lines · Russell King - ARM Linux
Quoted 17 lines · Jaya Kumar
Quoted 9 lines · eric miao
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.Is it possible that LCDCLK being requested by device other than
pxa_device_fb?? Could you give an example and we may work out a better solution.You're right. I think LCDCLK is only ever requested by
pxa_device_fb.I see now that instead of doing:
drivers/video/pxafb.c +1
-1- fbi->clk =clk_get (dev,"LCDCLK" ); + fbi->clk =clk_get (inf->clkdev,"LCDCLK" );
Quoted 9 lines
Quoted 5 lines
a better solution would be to directly use
pxa_device_fb:(quoted diff) +1
-1- fbi->clk = clk_get(dev, "LCDCLK"); + fbi->clk = clk_get(pxa_device_fb.dev, "LCDCLK");and then I can avoid doing the clkdev ugliness.
PXA devices (intentionally) aren't exported. Nor are they going to be, so the above will fail if built as a module.
Ah... I think this may be the cause of all my troubles. I've been trying to support am200epd working as a module, and allow it to rmmod cleanly, hence the inability to use pxa_device_fb through set_pxa_fb_info. If module support isn't important then I can happily take out unload support from am200epd and probably can then use set_pxa_fb_info and also reduce complexity in other parts of the metronomefb, am200epd, pxafb code.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 30 lines · Jaya Kumar
Quoted 18 lines · Russell King - ARM Linux
Quoted 17 lines · Jaya Kumar
Quoted 9 lines · eric miao
Quoted 4 lines · Jaya Kumar
These changes are to make it possible for a secondary driver to share the pxafb framebuffer. The changes include:
- adding clkdev entry inpxafb_mach_infoso that a driver can pass in the correct struct device owner for the LCDCLK.Is it possible that LCDCLK being requested by device other than
pxa_device_fb?? Could you give an example and we may work out a better solution.You're right. I think LCDCLK is only ever requested by
pxa_device_fb.I see now that instead of doing:
drivers/video/pxafb.c +1
-1- fbi->clk =clk_get (dev,"LCDCLK" ); + fbi->clk =clk_get (inf->clkdev,"LCDCLK" );Quoted 9 lines
Quoted 5 lines
a better solution would be to directly use
pxa_device_fb:(quoted diff) +1
-1- fbi->clk = clk_get(dev, "LCDCLK"); + fbi->clk = clk_get(pxa_device_fb.dev, "LCDCLK");and then I can avoid doing the clkdev ugliness.
PXA devices (intentionally) aren't exported. Nor are they going to be, so the above will fail if built as a module.
Quoted 8 lines
Ah... I think this may be the cause of all my troubles. I've been trying to support am200epd working as a module, and allow it to rmmod cleanly, hence the inability to use
pxa_device_fbthroughset_pxa_fb_info. If module support isn't important then I can happily take out unload support from am200epd and probably can then useset_pxa_fb_infoand also reduce complexity in other parts of the metronomefb, am200epd, pxafb code.
Hi Eric,
I've run into some difficulties. set_pxa_fb_info is:
void __init set_pxa_fb_info(struct pxafb_mach_info *info)
and not exported. Therefore am200epd can't be built as a module now that it depends on set_pxa_fb_info. That is fine, I switched am200epd to a built-in. But then because set_pxa_fb_info is __init, it disappears before am200epd is ready to call it. This is because am200epd needs metronomefb's framebuffer size and info which it only finds out after full boot into userspace when it gets its firmware from a udev script. I think this means that I would also need to make metronomefb a built-in and figure out how to compile in metronome's firmware. I haven't figured out how to do the latter yet.
I started thinking about maybe creating something different, like maybe set_mod_pxa_fb_info that would work more dynamically (ie: alloc a platform_device dynamically, thus making it possible for device_release to work, rather than using a static struct pxa_device_fb) and allow for module support without requiring any exports other than itself. Is this something that's of interest or should I focus on the former?
Thanks,
jaya
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 6 lines
Hi Eric,
I've run into some difficulties.
set_pxa_fb_infois:void
__initset_pxa_fb_info(struct pxafb_mach_info *info)
Quoted 10 lines
and not exported. Therefore am200epd can't be built as a module now that it depends on
set_pxa_fb_info. That is fine, I switched am200epd to a built-in. But then becauseset_pxa_fb_infois__init, it disappears before am200epd is ready to call it. This is because am200epd needs metronomefb's framebuffer size and info which it only finds out after full boot into userspace when it gets its firmware from a udev script. I think this means that I would also need to make metronomefb a built-in and figure out how to compile in metronome's firmware. I haven't figured out how to do the latter yet.
I see no reason why set_pxa_fb_info() cannot be exported, though its primary use is in the board setup code.
Quoted 7 lines
I started thinking about maybe creating something different, like maybe
set_mod_pxa_fb_infothat would work more dynamically (ie: alloc aplatform_devicedynamically, thus making it possible fordevice_releaseto work, rather than using a static structpxa_device_fb) and allow for module support without requiring any exports other than itself. Is this something that's of interest or should I focus on the former?
That sounds a bit trickier maybe we should avoid.
Quoted 4 lines
Thanks,
jaya
Signature · 8 lines
Cheers - eric ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 1/5] pxafb: add shared framebuffer interface
Quoted 3 lines · eric miao
I see no reason why
set_pxa_fb_info()cannot be exported, though its primary use is in the board setup code.
Yup, I see now. In the v6 patchset, I managed to use set_pxa_fb_info by converting am200epd to a builtin and also changing the way we do setup_fb for metronomefb. So I'm able to use set_pxa_fb_info without changes now. :-)
Quoted 11 lines
Quoted 8 lines
I started thinking about maybe creating something different, like maybe
set_mod_pxa_fb_infothat would work more dynamically (ie: alloc aplatform_devicedynamically, thus making it possible fordevice_releaseto work, rather than using a static structpxa_device_fb) and allow for module support without requiring any exports other than itself. Is this something that's of interest or should I focus on the former?That sounds a bit trickier maybe we should avoid.
Agreed.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
RFC 2/5 gumstix: conversion to MFP support and add bluetooth support
In reply to Jaya KumarThis patch converts gumstix over to the MFP configuration system and adds bluetooth support. Added a CLK_32K clock to enable bluetooth.
--- arch/arm/mach-pxa/gumstix.c | 77 +++++++++++++++++++++++++++++++++--------- arch/arm/mach-pxa/pxa25x.c | 31 +++++++++++++++++ 2 files changed, 91 insertions(+), 17 deletions(-)
arch/arm/mach-pxa/gumstix.c +60 -17
@@ -20,8 +20,12 @@#include <linux/init.h> #include <linux/platform_device.h> #include <linux/interrupt.h> +#include <linux/delay.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/gpio.h> +#include <linux/err.h> +#include <linux/clk.h> #include <asm/setup.h> #include <asm/memory.h>
@@ -40,7 +44,7 @@#include <asm/arch/pxa-regs.h> #include <asm/arch/pxa2xx-regs.h> -#include <asm/arch/pxa2xx-gpio.h> +#include <asm/arch/mfp-pxa25x.h> #include "generic.h"
@@ -85,21 +89,8 @@ static struct platform_device *devices[] __initdata = { };#ifdef CONFIG_MMC_PXA -static struct pxamci_platform_data gumstix_mci_platform_data; - -static int gumstix_mci_init (struct device *dev,irq_handler_t detect_int, -void *data) -{ -pxa_gpio_mode (GPIO6_MMCCLK_MD ); -pxa_gpio_mode (GPIO53_MMCCLK_MD ); -pxa_gpio_mode (GPIO8_MMCCS0_MD ); - -return 0 ; -} -static struct pxamci_platform_data gumstix_mci_platform_data = { .ocr_mask =MMC_VDD_32_33 |MMC_VDD_33_34 , - .init = gumstix_mci_init, };static void __init gumstix_mmc_init (void )
@@ -109,11 +100,11 @@ static void __init gumstix_mmc_init(void)#else static void __init gumstix_mmc_init (void ) { -printk (KERN_INFO "Gumstix mmc disabled\n" ); +pr_debug ("Gumstix mmc disabled\n" ); }#endif -#ifdef CONFIG_USB_GADGET_PXA2XX +#ifdef CONFIG_USB_GADGET_PXA25X static struct pxa2xx_udc_mach_info gumstix_udc_info__initdata = { .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
@@ -126,12 +117,64 @@ static void __init gumstix_udc_init(void)#else static void gumstix_udc_init (void ) { -printk (KERN_INFO "Gumstix udc is disabled\n" ); +pr_debug ("Gumstix udc is disabled\n" ); }#endif +#ifdef CONFIG_BT +static void __init gumstix_bluetooth_init (void ) +{ +int err; +struct clk *clk32k; + + clk32k =clk_get (NULL ,"CLK_32K" ); +if (IS_ERR (clk32k)) { +pr_err ("gumstix: failed to find 32kHz clock\n" ); +return ; + } +clk_enable (clk32k); + + err =gpio_direction_output (GPIO_GUMSTIX_BTRESET ,1 ); +if (err) { +pr_err ("gumstix: can't reset bluetooth\n" ); +return ; + } +gpio_set_value (GPIO_GUMSTIX_BTRESET ,0 ); +udelay (100 ); +gpio_set_value (GPIO_GUMSTIX_BTRESET ,1 ); +} +#else +static void gumstix_bluetooth_init (void ) +{ +pr_debug ("Gumstix Bluetooth is disabled\n" ); +} +#endif + +static unsigned long gumstix_pin_config[]__initdata = { + GPIO12_32KHz, +/* BTUART */ +GPIO42_HWUART_RXD , +GPIO43_HWUART_TXD , +GPIO44_HWUART_CTS , +GPIO45_HWUART_RTS , +/* MMC */ +GPIO6_MMC_CLK , +GPIO53_MMC_CLK , +GPIO8_MMC_CS0 , +/* these are used by AM200EPD */ +GPIO51_GPIO , +GPIO49_GPIO , +GPIO48_GPIO , +GPIO32_GPIO , +GPIO17_GPIO , +GPIO16_GPIO , +}; +static void __init gumstix_init (void ) { +pxa2xx_mfp_config (ARRAY_AND_SIZE (gumstix_pin_config)); + +gumstix_bluetooth_init ();gumstix_udc_init ();gumstix_mmc_init (); (void )platform_add_devices (devices,ARRAY_SIZE (devices));
arch/arm/mach-pxa/pxa25x.c +31 -0
@@ -22,6 +22,7 @@#include <linux/platform_device.h> #include <linux/suspend.h> #include <linux/sysdev.h> +#include <linux/delay.h> #include <asm/hardware.h> #include <asm/arch/irqs.h>
@@ -155,6 +156,30 @@ static const struct clkops clk_pxa25x_gpio11_ops = { .disable = clk_gpio11_disable, }; +static void clk_32k_enable (struct clk *clk) +{ +int timeout =500 ; + +if (!(OSCC &OSCC_OOK )) +pr_warning ("32kHz clock was not on. Bootloader may need to " +"be updated\n" ); +else +return ; + +OSCC |=OSCC_OON ; +do { +if (OSCC &OSCC_OOK ) +break ; +udelay (1 ); + }while (--timeout); +if (!timeout) +pr_err ("Failed to start 32kHz clock\n" ); +} + +static const struct clkops clk_32k_ops = { + .enable = clk_32k_enable, +}; +/* * 3.6864MHz -> OST, GPIO, SSP, PWM, PLLs (95.842MHz, 147.456MHz) * 95.842MHz -> MMC 19.169MHz, I2C 31.949MHz, FICP 47.923MHz, USB 47.923MHz
@@ -169,6 +194,12 @@ static struct clk pxa25x_hwuart_clk =* Please be careful not to disrupt the ordering. */ static struct clk pxa25x_clks[] = { + { + .name ="CLK_32K" , + .ops = &clk_32k_ops, + .rate =32768 , + .delay =70 , + },INIT_CK ("LCDCLK" ,LCD , &clk_pxa25x_lcd_ops, &pxa_device_fb.dev),INIT_CKEN ("UARTCLK" ,FFUART ,14745600 ,1 , &pxa_device_ffuart.dev),INIT_CKEN ("UARTCLK" ,BTUART ,14745600 ,1 , &pxa_device_btuart.dev),
Signature · 8 lines
1.5.3.6 ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Re: [RFC 2.6.26-rc9 2/5] gumstix: conversion to MFP support and add bluetooth support
Quoted 3 lines · Jaya Kumar
This patch converts gumstix over to the MFP configuration system and adds bluetooth support. Added a
CLK_32Kclock to enable bluetooth.
The CLK_32KHz is assumed to be enabled always, so it's really not necessary to create a struct clk for it. Please remove that from this patch.
Quoted 199 lines
Signed-off-by Jaya Kumar <[email protected]>--- arch/arm/mach-pxa/gumstix.c | 77 +++++++++++++++++++++++++++++++++--------- arch/arm/mach-pxa/pxa25x.c | 31 +++++++++++++++++ 2 files changed, 91 insertions(+), 17 deletions(-)arch/arm/mach-pxa/gumstix.c +60
-17@@ -20,8 +20,12 @@#include <linux/init.h> #include <linux/platform_device.h> #include <linux/interrupt.h> +#include <linux/delay.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/gpio.h> +#include <linux/err.h> +#include <linux/clk.h> #include <asm/setup.h> #include <asm/memory.h> @@ -40,7 +44,7 @@#include <asm/arch/pxa-regs.h> #include <asm/arch/pxa2xx-regs.h> -#include <asm/arch/pxa2xx-gpio.h> +#include <asm/arch/mfp-pxa25x.h> #include "generic.h" @@ -85,21 +89,8 @@ static struct platform_device *devices[] __initdata = { };#ifdef CONFIG_MMC_PXA -static struct pxamci_platform_data gumstix_mci_platform_data; - -static int gumstix_mci_init (struct device *dev,irq_handler_t detect_int, -void *data) -{ -pxa_gpio_mode (GPIO6_MMCCLK_MD ); -pxa_gpio_mode (GPIO53_MMCCLK_MD ); -pxa_gpio_mode (GPIO8_MMCCS0_MD ); - -return 0 ; -} -static struct pxamci_platform_data gumstix_mci_platform_data = { .ocr_mask =MMC_VDD_32_33 |MMC_VDD_33_34 , - .init = gumstix_mci_init, };static void __init gumstix_mmc_init (void )@@ -109,11 +100,11 @@ static void __init gumstix_mmc_init(void)#else static void __init gumstix_mmc_init (void ) { -printk (KERN_INFO "Gumstix mmc disabled\n" ); +pr_debug ("Gumstix mmc disabled\n" ); }#endif -#ifdef CONFIG_USB_GADGET_PXA2XX +#ifdef CONFIG_USB_GADGET_PXA25X static struct pxa2xx_udc_mach_info gumstix_udc_info__initdata = { .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,@@ -126,12 +117,64 @@ static void __init gumstix_udc_init(void)#else static void gumstix_udc_init (void ) { -printk (KERN_INFO "Gumstix udc is disabled\n" ); +pr_debug ("Gumstix udc is disabled\n" ); }#endif +#ifdef CONFIG_BT +static void __init gumstix_bluetooth_init (void ) +{ +int err; +struct clk *clk32k; + + clk32k =clk_get (NULL ,"CLK_32K" ); +if (IS_ERR (clk32k)) { +pr_err ("gumstix: failed to find 32kHz clock\n" ); +return ; + } +clk_enable (clk32k); + + err =gpio_direction_output (GPIO_GUMSTIX_BTRESET ,1 ); +if (err) { +pr_err ("gumstix: can't reset bluetooth\n" ); +return ; + } +gpio_set_value (GPIO_GUMSTIX_BTRESET ,0 ); +udelay (100 ); +gpio_set_value (GPIO_GUMSTIX_BTRESET ,1 ); +} +#else +static void gumstix_bluetooth_init (void ) +{ +pr_debug ("Gumstix Bluetooth is disabled\n" ); +} +#endif + +static unsigned long gumstix_pin_config[]__initdata = { + GPIO12_32KHz, +/* BTUART */ +GPIO42_HWUART_RXD , +GPIO43_HWUART_TXD , +GPIO44_HWUART_CTS , +GPIO45_HWUART_RTS , +/* MMC */ +GPIO6_MMC_CLK , +GPIO53_MMC_CLK , +GPIO8_MMC_CS0 , +/* these are used by AM200EPD */ +GPIO51_GPIO , +GPIO49_GPIO , +GPIO48_GPIO , +GPIO32_GPIO , +GPIO17_GPIO , +GPIO16_GPIO , +}; +static void __init gumstix_init (void ) { +pxa2xx_mfp_config (ARRAY_AND_SIZE (gumstix_pin_config)); + +gumstix_bluetooth_init ();gumstix_udc_init ();gumstix_mmc_init (); (void )platform_add_devices (devices,ARRAY_SIZE (devices));arch/arm/mach-pxa/pxa25x.c +31
-1@@ -22,6 +22,7 @@#include <linux/platform_device.h> #include <linux/suspend.h> #include <linux/sysdev.h> +#include <linux/delay.h> #include <asm/hardware.h> #include <asm/arch/irqs.h> @@ -155,6 +156,30 @@ static const struct clkops clk_pxa25x_gpio11_ops = { .disable = clk_gpio11_disable, }; +static void clk_32k_enable (struct clk *clk) +{ +int timeout =500 ; + +if (!(OSCC &OSCC_OOK )) +pr_warning ("32kHz clock was not on. Bootloader may need to " +"be updated\n" ); +else +return ; + +OSCC |=OSCC_OON ; +do { +if (OSCC &OSCC_OOK ) +break ; +udelay (1 ); + }while (--timeout); +if (!timeout) +pr_err ("Failed to start 32kHz clock\n" ); +} + +static const struct clkops clk_32k_ops = { + .enable = clk_32k_enable, +}; +/* * 3.6864MHz -> OST, GPIO, SSP, PWM, PLLs (95.842MHz, 147.456MHz) * 95.842MHz -> MMC 19.169MHz, I2C 31.949MHz, FICP 47.923MHz, USB 47.923MHz @@ -169,6 +194,12 @@ static struct clk pxa25x_hwuart_clk =* Please be careful not to disrupt the ordering. */ static struct clk pxa25x_clks[] = { + { + .name ="CLK_32K" , + .ops = &clk_32k_ops, + .rate =32768 , + .delay =70 , + },INIT_CK ("LCDCLK" ,LCD , &clk_pxa25x_lcd_ops, &pxa_device_fb.dev),INIT_CKEN ("UARTCLK" ,FFUART ,14745600 ,1 , &pxa_device_ffuart.dev),INIT_CKEN ("UARTCLK" ,BTUART ,14745600 ,1 , &pxa_device_btuart.dev), --1.5.3.6
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
Signature · 8 lines
Cheers - eric ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 2/5] gumstix: conversion to MFP support and add bluetooth support
Quoted 9 lines · eric miao
Quoted 3 lines · Jaya Kumar
This patch converts gumstix over to the MFP configuration system and adds bluetooth support. Added a
CLK_32Kclock to enable bluetooth.The
CLK_32KHzis assumed to be enabled always, so it's really not necessary to create a struct clk for it. Please remove that from this patch.
Hi Eric,
Ok, I will take it out.
To clarify, the bulk of gumstix's that have been shipped all come with U-boot 1.1.4 which does not turn it on by default and so my intention based on your previous feedback was basically: if CLK_32K not on, then warn the user, and then turn on the clk32k so that bluetooth works on such boards.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Re: [RFC 2.6.26-rc9 2/5] gumstix: conversion to MFP support and add bluetooth support
Quoted 13 lines · Jaya Kumar
Quoted 9 lines · eric miao
Quoted 3 lines · Jaya Kumar
This patch converts gumstix over to the MFP configuration system and adds bluetooth support. Added a
CLK_32Kclock to enable bluetooth.The
CLK_32KHzis assumed to be enabled always, so it's really not necessary to create a struct clk for it. Please remove that from this patch.Hi Eric,
Quoted 8 lines
Ok, I will take it out.
To clarify, the bulk of gumstix's that have been shipped all come with U-boot 1.1.4 which does not turn it on by default and so my intention based on your previous feedback was basically: if
CLK_32Knot on, then warn the user, and then turn on the clk32k so that bluetooth works on such boards.
Then we should probably enable the 32K OSCC in the board init code instead, maybe gumstix_init_32K() in gumstix_init(). Feel free to fire another patch for this please, and leave enough comments.
Quoted 3 lines
Thanks,
jaya
Signature · 8 lines
Cheers - eric ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
RFC 3/5 am200epd: convert to shared fb and use gpio api
In reply to Jaya KumarThe original am200epd driver was designed with bad assumptions. It manipulated GPSR/GPLR registers directly. It relied on direct access to the pxa LCDC registers which have since conflicted with commit ce4fb7b892a6d6c6a0f87366b26fd834d2923dd7 . This patch moves it into mach-pxa and overhauls it to use pxafb's fb. It now uses the generic GPIO api.
--- arch/arm/mach-pxa/Kconfig | 9 + arch/arm/mach-pxa/Makefile | 1 + arch/arm/mach-pxa/am200epd.c | 340 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-pxa/devices.c | 1 + drivers/video/Kconfig | 13 -- drivers/video/Makefile | 1 - drivers/video/am200epd.c | 295 ------------------------------------ 7 files changed, 351 insertions(+), 309 deletions(-) create mode 100644 arch/arm/mach-pxa/am200epd.c delete mode 100644 drivers/video/am200epd.c
arch/arm/mach-pxa/Kconfig +9 -0
@@ -243,6 +243,15 @@ config PCM990_DISPLAY_NONE endchoice +config MACH_AM200EPD + depends on MACH_GUMSTIX_F + tristate "Enable AM200EPD board support" + select FB_METRONOME + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS + select FB_DEFERRED_IO config PXA_EZX bool "Motorola EZX Platform"
arch/arm/mach-pxa/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_CPU_PXA320) += pxa320.o # Specific board support obj-$(CONFIG_ARCH_GUMSTIX) += gumstix.o +obj-$(CONFIG_MACH_AM200EPD) += am200epd.o obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o obj-$(CONFIG_MACH_LOGICPD_PXA270) += lpd270.o obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o
arch/arm/mach-pxa/am200epd.c new file +340 -0
340 lines not on this page · raw message
arch/arm/mach-pxa/devices.c +1 -0
@@ -143,6 +143,7 @@ struct platform_device pxa_device_fb = { .num_resources = ARRAY_SIZE(pxafb_resources), .resource = pxafb_resources, }; +EXPORT_SYMBOL_GPL (pxa_device_fb);void __init set_pxa_fb_info (struct pxafb_mach_info *info) {
drivers/video/Kconfig +0 -13
@@ -1938,19 +1938,6 @@ config FB_XILINX framebuffer. ML300 carries a 640*480 LCD display on the board, ML403 uses a standard DB15 VGA connector. -config FB_AM200EPD - tristate "AM-200 E-Ink EPD devkit support" - depends on FB && ARCH_PXA && MMU - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO - select FB_METRONOME - help - This enables support for the Metronome display controller used on - the E-Ink AM-200 EPD devkit. - config FB_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" depends on FB
drivers/video/Makefile +0 -1
@@ -29,7 +29,6 @@ obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o # Hardware specific drivers go first obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o -obj-$(CONFIG_FB_AM200EPD) += am200epd.o obj-$(CONFIG_FB_ARC) += arcfb.o obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
drivers/video/am200epd.c deleted +0 -295
295 lines not on this page · raw message
Signature · 8 lines
1.5.3.6 ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
RFC 4/5 metronomefb: convert printk to dev_dbg/err messages
In reply to Jaya KumarThis patch converts the printk messages in metronomefb to dev_dbg/err type messages.
--- drivers/video/metronomefb.c | 49 +++++++++++++++++++----------------------- 1 files changed, 22 insertions(+), 27 deletions(-)
drivers/video/metronomefb.c +22 -27
@@ -18,6 +18,8 @@* is provided as am200epd.c * */ +#define DEBUG 1 +#include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h>
@@ -40,15 +42,6 @@#include <asm/unaligned.h> - -#define DEBUG 1 -#ifdef DEBUG -#define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a) -#else -#define DPRINTK(f, a...) -#endif - -/* Display specific information */ #define DPY_W 832#define DPY_H 622
@@ -135,8 +128,8 @@ static u16 calc_img_cksum(u16 *start, int length)/* here we decode the incoming waveform file and populate metromem */ #define EXP_WFORM_SIZE 47001 -static int load_waveform (u8 *mem,size_t size,u8 *metromem,int m,int t, -u8 *frame_count) +static int __devinit load_waveform (u8 *mem,size_t size,int m,int t, +struct metronomefb_par *par) {int tta;int wmta;
@@ -148,9 +141,11 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,int wfm_idx, owfm_idx;int mem_idx =0 ;struct waveform_hdr *wfm_hdr; +u8 *metromem = par->metromem_wfm; +struct device *dev = par->info->dev;if (size !=EXP_WFORM_SIZE ) { -printk (KERN_ERR "Error: unexpected size %d != %d\n" , size, +dev_err (dev,"Error: unexpected size %d != %d\n" , size,EXP_WFORM_SIZE );return -EINVAL ; }
@@ -158,16 +153,16 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, wfm_hdr = (struct waveform_hdr *) mem;if (wfm_hdr->fvsn !=1 ) { -printk (KERN_ERR "Error: bad fvsn %x\n" , wfm_hdr->fvsn); +dev_err (dev,"Error: bad fvsn %x\n" , wfm_hdr->fvsn);return -EINVAL ; }if (wfm_hdr->luts !=0 ) { -printk (KERN_ERR "Error: bad luts %x\n" , wfm_hdr->luts); +dev_err (dev,"Error: bad luts %x\n" , wfm_hdr->luts);return -EINVAL ; } cksum =calc_cksum (32 ,47 , mem);if (cksum != wfm_hdr->wfm_cs) { -printk (KERN_ERR "Error: bad cksum %x != %x\n" , cksum, +dev_err (dev,"Error: bad cksum %x != %x\n" , cksum, wfm_hdr->wfm_cs);return -EINVAL ; }
@@ -175,7 +170,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, wfm_hdr->trc +=1 ;for (i =0 ; i <5 ; i++) {if (*(wfm_hdr->stuff2a + i) !=0 ) { -printk (KERN_ERR "Error: unexpected value in padding\n" ); +dev_err (dev,"Error: unexpected value in padding\n" );return -EINVAL ; } }
@@ -200,7 +195,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,return -EINVAL ; cksum =calc_cksum (sizeof (*wfm_hdr), cksum_idx, mem);if (cksum != mem[cksum_idx]) { -printk (KERN_ERR "Error: bad temperature range table cksum" +dev_err (dev,"Error: bad temperature range table cksum" " %x != %x\n" , cksum, mem[cksum_idx]);return -EINVAL ; }
@@ -212,7 +207,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,return -EINVAL ; cksum =calc_cksum (cksum_idx -3 , cksum_idx, mem);if (cksum != mem[cksum_idx]) { -printk (KERN_ERR "Error: bad mode table address cksum" +dev_err (dev,"Error: bad mode table address cksum" " %x != %x\n" , cksum, mem[cksum_idx]);return -EINVAL ; }
@@ -224,7 +219,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,return -EINVAL ; cksum =calc_cksum (cksum_idx -3 , cksum_idx, mem);if (cksum != mem[cksum_idx]) { -printk (KERN_ERR "Error: bad temperature table address cksum" +dev_err (dev,"Error: bad temperature table address cksum" " %x != %x\n" , cksum, mem[cksum_idx]);return -EINVAL ; }
@@ -259,11 +254,11 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,return -EINVAL ; cksum =calc_cksum (owfm_idx, cksum_idx, mem);if (cksum != mem[cksum_idx]) { -printk (KERN_ERR "Error: bad waveform data cksum" +dev_err (dev,"Error: bad waveform data cksum" " %x != %x\n" , cksum, mem[cksum_idx]);return -EINVAL ; } - *frame_count = (mem_idx/64 ); + par->frame_count = (mem_idx/64 );return 0 ; }
@@ -662,15 +657,15 @@ static int __devinit metronomefb_probe(struct platform_device *dev)b) process waveform and decode into metromem */ retval =request_firmware (&fw_entry,"metronome.wbf" , &dev->dev);if (retval <0 ) { -printk (KERN_ERR "metronomefb: couldn't get waveform\n" ); +dev_err (&dev->dev,"Failed to get waveform\n" ); goto err_dma_free; } - retval =load_waveform ((u8 *) fw_entry->data, fw_entry->size, - par->metromem_wfm,3 ,31 , &par->frame_count); + retval =load_waveform ((u8 *) fw_entry->data, fw_entry->size,3 ,31 , + par);release_firmware (fw_entry);if (retval <0 ) { -printk (KERN_ERR "metronomefb: couldn't process waveform\n" ); +dev_err (&dev->dev,"Failed processing waveform\n" ); goto err_dma_free; }
@@ -688,7 +683,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev) retval =fb_alloc_cmap (&info->cmap,8 ,0 );if (retval <0 ) { -printk (KERN_ERR "Failed to allocate colormap\n" ); +dev_err (&dev->dev,"Failed to allocate colormap\n" ); goto err_fb_rel; }
@@ -704,7 +699,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev)platform_set_drvdata (dev, info); -printk (KERN_INFO +dev_dbg (&dev->dev,"fb%d: Metronome frame buffer device, using %dK of video" " memory\n" , info->node, videomemorysize >>10 );
Signature · 8 lines
1.5.3.6 ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Re: [RFC 2.6.26-rc9 4/5] metronomefb: convert printk to dev_dbg/err messages
Quoted 3 lines · Jaya Kumar
This patch converts the printk messages in metronomefb to dev_dbg/err type messages.
This is always a good thing to do :)
Quoted 1 line
Signed-off-by Jaya Kumar <[email protected]>
With the removal of "#define DEBUG 1",
Quoted 9 lines
--- drivers/video/metronomefb.c | 49 +++++++++++++++++++----------------------- 1 files changed, 22 insertions(+), 27 deletions(-)drivers/video/metronomefb.c +0
-0
drivers/video/metronomefb.c line 22
Quoted 5 lines
drivers/video/metronomefb.c +2
-0@@ -18,6 +18,8 @@* is provided as am200epd.c * */ +#define DEBUG 1 +
Don't leave DEBUG in the final patch please.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
RFC 5/5 metronomefb: changes to use separate framebuffer
In reply to Jaya KumarThese changes are used in order to support the use of a separate framebuffer provided by the platform device driver. Other changes are cleanup to error handling and order of release.
--- drivers/video/metronomefb.c | 225 +++++++++++++++++++++++++------------------ include/video/metronomefb.h | 22 ++--- 2 files changed, 138 insertions(+), 109 deletions(-)
drivers/video/metronomefb.c +131 -94
@@ -46,16 +46,59 @@#define DPY_W 832#define DPY_H 622 +static int user_wfm_size; +/* frame differs from image. frame includes non-visible pixels */ struct epd_frame {int fw;/* frame width */ int fh;/* frame height */ +u16 config[4 ]; +int wfm_size; };static struct epd_frame epd_frame_table[] = { { - .fw =832 , - .fh =622 + .fw =832 , + .fh =622 , + .config = { +15 /* sdlew */ + |2 <<8 /* sdosz */ + |0 <<11 /* sdor */ + |0 <<12 /* sdces */ + |0 <<15 ,/* sdcer */ +42 /* gdspl */ + |1 <<8 /* gdr1 */ + |1 <<9 /* sdshr */ + |0 <<15 ,/* gdspp */ +18 /* gdspw */ + |0 <<15 ,/* dispc */ +599 /* vdlc */ + |0 <<11 /* dsi */ + |0 <<12 ,/* dsic */ + }, + .wfm_size =47001 , + }, + { + .fw =1088 , + .fh =791 , + .config = { +0x0104 , +0x031f , +0x0088 , +0x02ff , + }, + .wfm_size =46770 , + }, + { + .fw =1200 , + .fh =842 , + .config = { +0x0101 , +0x030e , +0x0012 , +0x0280 , + }, + .wfm_size =46770 , }, };
@@ -127,7 +170,6 @@ static u16 calc_img_cksum(u16 *start, int length) }/* here we decode the incoming waveform file and populate metromem */ -#define EXP_WFORM_SIZE 47001static int __devinit load_waveform (u8 *mem,size_t size,int m,int t,struct metronomefb_par *par) {
@@ -144,9 +186,12 @@ static int __devinit load_waveform(u8 *mem, size_t size, int m, int t,u8 *metromem = par->metromem_wfm;struct device *dev = par->info->dev; -if (size !=EXP_WFORM_SIZE ) { +if (user_wfm_size) + epd_frame_table[par->dt].wfm_size = user_wfm_size; + +if (size != epd_frame_table[par->dt].wfm_size) {dev_err (dev,"Error: unexpected size %d != %d\n" , size, -EXP_WFORM_SIZE ); + epd_frame_table[par->dt].wfm_size);return -EINVAL ; }
@@ -330,44 +375,17 @@ static int __devinit metronome_powerup_cmd(struct metronomefb_par *par)static int __devinit metronome_config_cmd (struct metronomefb_par *par) { -int i; -u16 cs; -/* setup config command we can't immediately set the opcode since the controller -will try parse the command before we've set it all up -so we just set cs here and set the opcode at the end */ - - cs =0xCC10 ; - -/* set the 12 args ( 8 bytes ) for config. see spec for meanings */ - i =0 ; - par->metromem_cmd->args[i] =15 /* sdlew */ - |2 <<8 /* sdosz */ - |0 <<11 /* sdor */ - |0 <<12 /* sdces */ - |0 <<15 ;/* sdcer */ - cs += par->metromem_cmd->args[i++]; - - par->metromem_cmd->args[i] =42 /* gdspl */ - |1 <<8 /* gdr1 */ - |1 <<9 /* sdshr */ - |0 <<15 ;/* gdspp */ - cs += par->metromem_cmd->args[i++]; - - par->metromem_cmd->args[i] =18 /* gdspw */ - |0 <<15 ;/* dispc */ - cs += par->metromem_cmd->args[i++]; - - par->metromem_cmd->args[i] =599 /* vdlc */ - |0 <<11 /* dsi */ - |0 <<12 ;/* dsic */ - cs += par->metromem_cmd->args[i++]; +will try parse the command before we've set it all up */ +memcpy (par->metromem_cmd->args, epd_frame_table[par->dt].config, +sizeof (epd_frame_table[par->dt].config));/* the rest are 0 */ -memset ((u8 *) (par->metromem_cmd->args + i),0 , (32 -i)*2 ); +memset ((u8 *) (par->metromem_cmd->args +4 ),0 , (32 -4 )*2 ); - par->metromem_cmd->csum = cs; + par->metromem_cmd->csum =0xCC10 ; + par->metromem_cmd->csum +=calc_img_cksum (par->metromem_cmd->args,4 ); par->metromem_cmd->opcode =0xCC10 ;/* config cmd */ return par->board->met_wait_event (par);
@@ -403,12 +421,9 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par) {int res; - par->board->init_gpio_regs (par); - - par->board->init_lcdc_regs (par); - -/* now that lcd is setup, setup dma descriptor */ - par->board->post_dma_setup (par); + res = par->board->setup_io (par); +if (res) +return res; res =metronome_powerup_cmd (par);if (res)
@@ -425,16 +440,16 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par)static void metronomefb_dpy_update (struct metronomefb_par *par) { +int fbsize;u16 cksum;unsigned char *buf = (unsigned char __force *)par->info->screen_base; + fbsize = par->info->fix.smem_len;/* copy from vm to metromem */ -memcpy (par->metromem_img, buf,DPY_W *DPY_H ); +memcpy (par->metromem_img, buf, fbsize); - cksum =calc_img_cksum ((u16 *) par->metromem_img, - (epd_frame_table[0 ].fw *DPY_H )/2 ); - *((u16 *)(par->metromem_img) + - (epd_frame_table[0 ].fw *DPY_H )/2 ) = cksum; + cksum =calc_img_cksum ((u16 *) par->metromem_img, fbsize/2 ); + *((u16 *)(par->metromem_img) + fbsize/2 ) = cksum;metronome_display_cmd (par); }
@@ -569,8 +584,11 @@ static int __devinit metronomefb_probe(struct platform_device *dev)unsigned char *videomemory;struct metronomefb_par *par;const struct firmware *fw_entry; -int cmd_size, wfm_size, img_size, padding_size, totalsize; +int cmd_size, wfm_size, padding_size;int i; +int panel_type; +int fw, fh; +int epd_dt_index;/* pick up board specific routines */ board = dev->dev.platform_data;
@@ -581,39 +599,65 @@ static int __devinit metronomefb_probe(struct platform_device *dev)if (!try_module_get (board->owner))return -ENODEV ; + info =framebuffer_alloc (sizeof (struct metronomefb_par ), &dev->dev); +if (!info) + goto err; +/* we have two blocks of memory. info->screen_base which is vm, and is the fb used by apps. par->metromem which is physically contiguous memory and contains the display controller commands, waveform, processed image data and padding. this is the data pulled -by the device's LCD controller and pushed to Metronome */ - - videomemorysize = (DPY_W *DPY_H ); +by the device's LCD controller and pushed to Metronome. +the metromem memory is allocated by the board driver and +is provided to us */ + + panel_type = board->get_panel_type (); +switch (panel_type) { +case 6 : + epd_dt_index =0 ; +break ; +case 8 : + epd_dt_index =1 ; +break ; +case 97 : + epd_dt_index =2 ; +break ; +default : +dev_err (&dev->dev,"Unexpected panel type. Defaulting to 6\n" ); + epd_dt_index =0 ; +break ; + } + fw = epd_frame_table[epd_dt_index].fw; + fh = epd_frame_table[epd_dt_index].fh; + videomemorysize = fw * fh; videomemory =vmalloc (videomemorysize);if (!videomemory) -return -ENOMEM ; + goto err_fb_rel;memset (videomemory,0 , videomemorysize); - info =framebuffer_alloc (sizeof (struct metronomefb_par ), &dev->dev); -if (!info) - goto err_vfree; - info->screen_base = (char __force __iomem *)videomemory; info->fbops = &metronomefb_ops; + metronomefb_fix.line_length = fw; + metronomefb_var.xres = fw; + metronomefb_var.yres = fh; + metronomefb_var.xres_virtual = fw; + metronomefb_var.yres_virtual = fh; info->var = metronomefb_var; info->fix = metronomefb_fix; info->fix.smem_len = videomemorysize; par = info->par; par->info = info; par->board = board; + par->dt = epd_dt_index;init_waitqueue_head (&par->waitq);/* this table caches per page csum values. */ par->csum_table =vmalloc (videomemorysize/PAGE_SIZE );if (!par->csum_table) - goto err_csum_table; + goto err_vfree;/* the metromem buffer is divided as follows: command | CRC | padding
@@ -623,34 +667,26 @@ static int __devinit metronomefb_probe(struct platform_device *dev)eg: IW=832 IH=622 WS=128 */ - cmd_size =1 * epd_frame_table[0 ].fw; - wfm_size = ((16 *1024 +2 + epd_frame_table[0 ].fw -1 ) - / epd_frame_table[0 ].fw) * epd_frame_table[0 ].fw; - img_size = epd_frame_table[0 ].fh * epd_frame_table[0 ].fw; - padding_size =4 * epd_frame_table[0 ].fw; - totalsize = cmd_size + wfm_size + img_size + padding_size; - par->metromemsize =PAGE_ALIGN (totalsize +256 ); -DPRINTK ("desired memory size = %d\n" , par->metromemsize); - dev->dev.coherent_dma_mask =0xffffffffull ; - par->metromem =dma_alloc_writecombine (&dev->dev, par->metromemsize, - &par->metromem_dma,GFP_KERNEL ); + cmd_size =1 * fw; + wfm_size = ((16 *1024 +2 + fw -1 ) / fw) * fw; + padding_size =4 * fw; + par->extra_size = cmd_size + wfm_size + padding_size; + retval = par->board->setup_fb (par); +if (retval) { +dev_err (&dev->dev,"Failed to setup fb\n" ); + goto err_csum_table; + } +/* after this point we should have a framebuffer */ if (!par->metromem) { -printk (KERN_ERR -"metronomefb: unable to allocate dma buffer\n" ); - goto err_vfree; + retval = -EINVAL ; + goto err_csum_table; } info->fix.smem_start = par->metromem_dma; par->metromem_cmd = (struct metromem_cmd *) par->metromem; par->metromem_wfm = par->metromem + cmd_size; par->metromem_img = par->metromem + cmd_size + wfm_size; - par->metromem_img_csum = (u16 *) (par->metromem_img + - (epd_frame_table[0 ].fw *DPY_H )); -DPRINTK ("img offset=0x%x\n" , cmd_size + wfm_size); - par->metromem_desc = (struct metromem_desc *) (par->metromem + cmd_size - + wfm_size + img_size + padding_size); - par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size - + img_size + padding_size; + par->metromem_img_csum = (u16 *) (par->metromem_img + (fw * fh));/* load the waveform in. assume mode 3, temp 31 for now a) request the waveform file from userspace
@@ -658,7 +694,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev) retval =request_firmware (&fw_entry,"metronome.wbf" , &dev->dev);if (retval <0 ) {dev_err (&dev->dev,"Failed to get waveform\n" ); - goto err_dma_free; + goto err_csum_table; } retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, 3, 31,
@@ -666,11 +702,11 @@ static int __devinit metronomefb_probe(struct platform_device *dev)release_firmware (fw_entry);if (retval <0 ) {dev_err (&dev->dev,"Failed processing waveform\n" ); - goto err_dma_free; + goto err_csum_table; }if (board->setup_irq (info)) - goto err_dma_free; + goto err_csum_table; retval =metronome_init_regs (par);if (retval <0 )
@@ -684,7 +720,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev) retval =fb_alloc_cmap (&info->cmap,8 ,0 );if (retval <0 ) {dev_err (&dev->dev,"Failed to allocate colormap\n" ); - goto err_fb_rel; + goto err_free_irq; }/* set cmap */
@@ -707,17 +743,15 @@ static int __devinit metronomefb_probe(struct platform_device *dev) err_cmap:fb_dealloc_cmap (&info->cmap); -err_fb_rel: -framebuffer_release (info); err_free_irq: - board->free_irq (info); -err_dma_free: -dma_free_writecombine (&dev->dev, par->metromemsize, par->metromem, - par->metromem_dma); + board->cleanup (par); err_csum_table:vfree (par->csum_table); err_vfree:vfree (videomemory); +err_fb_rel: +framebuffer_release (info); +err:module_put (board->owner);return retval; }
@@ -728,15 +762,15 @@ static int __devexit metronomefb_remove(struct platform_device *dev)if (info) {struct metronomefb_par *par = info->par; + +unregister_framebuffer (info);fb_deferred_io_cleanup (info); -dma_free_writecombine (&dev->dev, par->metromemsize, - par->metromem, par->metromem_dma);fb_dealloc_cmap (&info->cmap); + par->board->cleanup (par);vfree (par->csum_table); -unregister_framebuffer (info);vfree ((void __force *)info->screen_base); - par->board->free_irq (info);module_put (par->board->owner); +dev_dbg (&dev->dev,"calling release\n" );framebuffer_release (info); }return 0 ;
@@ -761,6 +795,9 @@ static void __exit metronomefb_exit(void)platform_driver_unregister (&metronomefb_driver); } +module_param (user_wfm_size, uint,0 ); +MODULE_PARM_DESC (user_wfm_size,"Set custom waveform size" ); +module_init (metronomefb_init);module_exit (metronomefb_exit);
include/video/metronomefb.h +7 -15
@@ -12,14 +12,6 @@ #ifndef _LINUX_METRONOMEFB_H_ #define _LINUX_METRONOMEFB_H_ -/* address and control descriptors used by metronome controller */ -struct metromem_desc { - u32 mFDADR0; - u32 mFSADR0; - u32 mFIDR0; - u32 mLDCMD0; -}; - /* command structure used by metronome controller */ struct metromem_cmd { u16 opcode;
@@ -30,33 +22,33 @@ struct metromem_cmd {/* struct used by metronome. board specific stuff comes from *board */ struct metronomefb_par {unsigned char *metromem; -struct metromem_desc *metromem_desc;struct metromem_cmd *metromem_cmd;unsigned char *metromem_wfm;unsigned char *metromem_img;u16 *metromem_img_csum;u16 *csum_table; -int metromemsize;dma_addr_t metromem_dma; -dma_addr_t metromem_desc_dma;struct fb_info *info;struct metronome_board *board;wait_queue_head_t waitq;u8 frame_count; +int extra_size; +int dt; };/* board specific routines */ struct metronome_board {struct module *owner; -void (*free_irq)(struct fb_info *); -void (*init_gpio_regs)(struct metronomefb_par *); -void (*init_lcdc_regs)(struct metronomefb_par *); -void (*post_dma_setup)(struct metronomefb_par *); +struct module *fbmaster;void (*set_rst)(struct metronomefb_par *,int );void (*set_stdby)(struct metronomefb_par *,int ); +void (*cleanup)(struct metronomefb_par *);int (*met_wait_event)(struct metronomefb_par *);int (*met_wait_event_intr)(struct metronomefb_par *);int (*setup_irq)(struct fb_info *); +int (*setup_fb)(struct metronomefb_par *); +int (*setup_io)(struct metronomefb_par *); +int (*get_panel_type)(void ); };#endif
Signature · 8 lines
1.5.3.6 ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08