SM501: core (mfd) driver
Subsystems (3)
This is a proposed core driver for the Silicon Motion SM501 to support the block-specific drivers.
The patch provides support for either a platform or PCI attached SM501, to initialise the core and then export new devices for the function drivers to attach to.
Included in the patch is a set of register defines for most of the blocks and the SM501 framebuffer.
For more information, there is a Documentation/SM501.txt which explains the design decisions in the patch.
Documentation/SM501.txt +58 -0
@@ -0,0 +1,58 @@ + SM501 Driver + ============ + +Copyright 2006 Simtec Electronics + +Core +---- + +The core driver in drivers/mfd provides common services for the +drivers which manage the specific hardware blocks. These services +include locking for common registers, clock control and resource +management. + +The core registers drivers for both PCI and generic bus based +chips via the platform device and driver system. + +On detection of a device, the core initialises the chip (which may +be specified by the platfrom data) and then exports the selected +peripheral set as platform devices for the specific drivers. + +The core re-uses the platform device system as the platform device +system provides enough features to support the drivers without the +need to create a new bus-type and the associated code to go with it. + + +Resources +--------- + +Each peripheral's view of the device is implicitly narrowed to the +specific set of resources it requires in order to function correctly. + +The centralised memory allocation allows the driver to ensure that the +maximum possible resource allocation can be made to the video subsystem +as this is by-far the most resource-sensitive of the on-chip functions. + +The primary issue with memory allocation is that of moving the video +buffers once a display mode is chosen. Indeed when a video mode change +occurs the memory footprint of the video subsystem changes. + +Since Video memory is difficult to move without changing the display +(unless sufficient contiguous memory can be provided for the old and new +modes simultaneously) the video driver fully utilises the memory area +given to it by aligning fb0 to the start of the area and fb1 to the end +of it. Any memory left over in the middle is used for the acceleration +functions, which are transient and thus their location is less critical +as it can be moved. + + +Configuration +------------- + +The platform device driver uses a set of platform data to pass +configurations through to the core and the subsidiary drivers +so that there can be sujpport for more than one system carrying +an SM501 built into a single kernel image. + +Currently the PCI driver assumes the manufacturer's reference +design.
drivers/mfd/Kconfig +14 -0
@@ -2,6 +2,20 @@ # Multifunction miscellaneous devices # +menu "Multifunction device drivers" + +config MFD_SM501 + tristate "Support for Silicon Motion SM501" + ---help--- + This is the core driver for the Silicon motion SM501 multimedia + companion chip. This device is a multifunction device which may + provide numerous interfaces including USB host controller USB gadget, + Asyncronous Serial ports, Audio functions and a dual display video + interface. The device may be connected by PCI or local bus with + varying functions enabled. + +endmenu + menu "Multimedia Capabilities Port drivers" depends on ARCH_SA1100
drivers/mfd/Makefile +2 -0
@@ -2,6 +2,8 @@ # Makefile for multifunction miscellaneous devices # +obj-$(CONFIG_MFD_SM501) += sm501.o + obj-$(CONFIG_MCP) += mcp-core.o obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
drivers/mfd/sm501.c +1061 -0
1,061 lines not on this page · raw message
include/linux/sm501-regs.h +284 -0
284 lines not on this page · raw message
include/linux/sm501.h +152 -0
152 lines not on this page · raw message
Documentation/SM501.txt +58 -0
58 lines not on this page · raw message
drivers/mfd/Kconfig +14 -0
@@ -2,6 +2,20 @@ # Multifunction miscellaneous devices # +menu "Multifunction device drivers" + +config MFD_SM501 + tristate "Support for Silicon Motion SM501" + ---help--- + This is the core driver for the Silicon motion SM501 multimedia + companion chip. This device is a multifunction device which may + provide numerous interfaces including USB host controller USB gadget, + Asyncronous Serial ports, Audio functions and a dual display video + interface. The device may be connected by PCI or local bus with + varying functions enabled. + +endmenu + menu "Multimedia Capabilities Port drivers" depends on ARCH_SA1100
drivers/mfd/Makefile +2 -0
@@ -2,6 +2,8 @@ # Makefile for multifunction miscellaneous devices # +obj-$(CONFIG_MFD_SM501) += sm501.o + obj-$(CONFIG_MCP) += mcp-core.o obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
drivers/mfd/sm501.c +1061 -0
1,061 lines not on this page · raw message
include/linux/sm501-regs.h +284 -0
270 lines not on this page · raw message
include/linux/sm501.h +152 -0
152 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
Part of the diff is not shown here. View the raw message.
Hi,
some review comments below
drivers/mfd/sm501.c line 40
Quoted 4 lines
drivers/mfd/sm501.c +4
-0+ +struct sm501_devdata { +spinlock_t reg_lock; +struct semaphore clock_lock;
can't this be a mutex instead ?
drivers/mfd/sm501.c line 57
Quoted 4 lines
drivers/mfd/sm501.c +4
-0+#ifdef CONFIG_DEBUG +static unsigned int misc_div[] = { + [0 ] =1 , + [1] = 2,
can this be const ?
drivers/mfd/sm501.c line 299
Quoted 11 lines
drivers/mfd/sm501.c +11
-0+ +int sm501_unit_power (struct device *dev,unsigned int unit,unsigned int to) +{ +struct sm501_devdata *sm =dev_get_drvdata (dev); +unsigned long mode =readl (sm->regs +SM501_POWER_MODE_CONTROL ); +unsigned long gate =readl (sm->regs +SM501_CURRENT_GATE ); +unsigned long clock =readl (sm->regs +SM501_CURRENT_CLOCK ); + + mode &=3 ;/* get current power mode */ + +down (&sm->clock_lock);
eh shouldn't you do the readl()'s inside the semaphore (or mutex) area?
drivers/mfd/sm501.c line 346
Quoted 7 lines
drivers/mfd/sm501.c +7
-0+ +writel (mode, sm->regs +SM501_POWER_MODE_CONTROL ); + +dev_dbg (sm->dev,"gate %08lx, clock %08lx, mode %08lx\n" , + gate, clock, mode); + +msleep (16 );
you're missing a PCI posting flush here
(if you don't know what this is please ask)
Review
Quoted 2 lines
(quoted diff) +2
-0+ sm->dev = &dev->dev; + sm->irq = dev->irq;
you shouldn't look at dev->irq ...
drivers/mfd/sm501.c line 923
Quoted 7 lines
drivers/mfd/sm501.c +7
-0+ +/* set a hopefully unique id for our child platform devices */ + sm->pdev_id =32 + dev->devfn; + +pci_set_drvdata (dev, sm); + + err =pci_enable_device (dev);
.. before calling pci_enable_device() since pci_enable_device() may be the one that sets the dev->irq value to it's final value in the first place
drivers/mfd/sm501.c line 957
Quoted 5 lines
drivers/mfd/sm501.c +5
-0+ sm->io_res = &dev->resource[1 ]; + sm->mem_res = &dev->resource[0 ]; + + sm->regs =ioremap (pci_resource_start (dev,1 ), +pci_resource_len (dev,1 ));
you know how to use pci_resource_start() and co.. why not use them 3 lines higher ? ;)
the driver looks quite clean otherwise btw, great work!
-
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
Quoted 9 lines · Arjan van de Ven
Hi,
some review comments below
drivers/mfd/sm501.c line 40
Quoted 4 lines
drivers/mfd/sm501.c +4
-0+ +struct sm501_devdata { +spinlock_t reg_lock; +struct semaphore clock_lock;can't this be a mutex instead ?
I wasn't sure what context the callers would be when I originally wrote this code. I will have a careful think of what this will be used in, and then have a look at changing it.
Quoted 6 lines
drivers/mfd/sm501.c line 57
Quoted 4 lines
drivers/mfd/sm501.c +4
-0+#ifdef CONFIG_DEBUG +static unsigned int misc_div[] = { + [0 ] =1 , + [1] = 2,can this be const ?
Yes, will change.
Quoted 5 lines
Quoted 5 lines
drivers/mfd/sm501.c +5
-0+ +int sm501_unit_power (struct device *dev,unsigned int unit,unsigned int to) +{ +struct sm501_devdata *sm =dev_get_drvdata (dev); +unsigned long mode =readl (sm->regs +SM501_POWER_MODE_CONTROL );
Quoted 8 lines
drivers/mfd/sm501.c line 299
Quoted 6 lines
drivers/mfd/sm501.c +6
-0+unsigned long gate =readl (sm->regs +SM501_CURRENT_GATE ); +unsigned long clock =readl (sm->regs +SM501_CURRENT_CLOCK ); + + mode &=3 ;/* get current power mode */ + +down (&sm->clock_lock);eh shouldn't you do the readl()'s inside the semaphore (or mutex) area?
Thanks, mistake when fitting locking in, fixed for next release.
Quoted 10 lines
drivers/mfd/sm501.c line 346
Quoted 7 lines
drivers/mfd/sm501.c +7
-0+ +writel (mode, sm->regs +SM501_POWER_MODE_CONTROL ); + +dev_dbg (sm->dev,"gate %08lx, clock %08lx, mode %08lx\n" , + gate, clock, mode); + +msleep (16 );you're missing a PCI posting flush here
(if you don't know what this is please ask)
Is this a read from an device register to cause the PCI writes to happen? Would reading SM501_POWER_MODE_CONTROL be ok, or does it require a different register?
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ sm->dev = &dev->dev; + sm->irq = dev->irq;you shouldn't look at
dev->irq...
Quoted 11 lines
drivers/mfd/sm501.c line 923
Quoted 7 lines
drivers/mfd/sm501.c +7
-0+ +/* set a hopefully unique id for our child platform devices */ + sm->pdev_id =32 + dev->devfn; + +pci_set_drvdata (dev, sm); + + err =pci_enable_device (dev);.. before calling
pci_enable_device()sincepci_enable_device()may be the one that sets thedev->irqvalue to it's final value in the first place
Ok, fixed.
Quoted 8 lines
drivers/mfd/sm501.c line 957
Quoted 5 lines
drivers/mfd/sm501.c +5
-0+ sm->io_res = &dev->resource[1 ]; + sm->mem_res = &dev->resource[0 ]; + + sm->regs =ioremap (pci_resource_start (dev,1 ), +pci_resource_len (dev,1 ));you know how to use
pci_resource_start()and co.. why not use them 3 lines higher ? ;)
These pointers where meant to be kept for setting new resources' parent pointers, will check what happened.
Quoted 2 lines
the driver looks quite clean otherwise btw, great work!
Thanks for the prompt and useful reply.
Signature · 3 lines
Ben ([email protected], http://www.fluff.org/) 'a smiley only costs 4 bytes'
Quoted 11 lines · Ben Dooks
Quoted 10 lines
drivers/mfd/sm501.c line 346
Quoted 7 lines
drivers/mfd/sm501.c +7
-0+ +writel (mode, sm->regs +SM501_POWER_MODE_CONTROL ); + +dev_dbg (sm->dev,"gate %08lx, clock %08lx, mode %08lx\n" , + gate, clock, mode); + +msleep (16 );you're missing a PCI posting flush here
(if you don't know what this is please ask)
Quoted 2 lines
Is this a read from an device register to cause the PCI writes to happen?
yup
Quoted 2 lines
Would reading
SM501_POWER_MODE_CONTROLbe ok, or does
it require a different register?
any register is ok, you can read the same one just fine.
greetings,
Arjan van de Ven
Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org