* Re: [PATCH 1/7] pwm: Add pwm core driver [not found] ` <F45880696056844FA6A73F415B568C69532DC2FC60@EXDCVYMBSTM006.EQ1STM.local> @ 2010-09-28 21:04 ` Lars-Peter Clausen 2010-09-29 4:49 ` Arun MURTHY 0 siblings, 1 reply; 6+ messages in thread From: Lars-Peter Clausen @ 2010-09-28 21:04 UTC (permalink / raw) To: Arun MURTHY Cc: eric.y.miao@gmail.com, linux@arm.linux.org.uk, Andrew Morton, kernel@pengutronix.de, philipp.zabel@gmail.com, robert.jarzmik@free.fr, Marek Vasut, rpurdie@rpsys.net, Samuel Ortiz, kgene.kim@samsung.com, linux-omap, broonie@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, Linus WALLEIJ, Mattias WALLIN, linux-arm-kernel, linux-mips@linux-mips.org, Arun Murthy, STEricsson_nomadik_linux Arun MURTHY wrote: >>>> Shouldn't PWM_DEVICES select HAVE_PWM? >>> >>> No not required, the entire concept is to remove HAVE_PWM and use >> PWM_CORE. >> >> Well in patch 4 you say that PWM_CORE is currently limited to ARM. >> Furthermore you >> change the pwm-backlight and pwm-led Kconfig entries to depend on >> HAVE_PWM || >> PWM_CORE. Adding a select HAVE_PWM here would make those changes >> unnecessary. > HAVE_PWM is retained just because the mips pwm driver is not aligned with the pwm core driver. > On mips pwm driver aligning to the pwm core driver HAVE_PWM will be replaced by PWM_CORE. > >> HAVE_PWM should be set, when pwm_* functions are available. When your >> pwm-core driver >> is selected they are available. > On applying this patch set pwm_* function will be exported in pwm_core driver and in mips pwm driver. > Since mips pwm driver is not aligned with the pwm core, HAVE_PWM is retained and removed in places where pwm drivers register to pwm core driver. pwm_{enable,disable,request,free} are the interface of the pwm api. Your pwm-core is one implementation of that interface. A somewhat special though, because it tries to be a generic implementation. There are still other implementations though. For example right now the mips jz4740 one. In my opinion HAVE_PWM should be defined if there is a implementation for the pwm interface is available. I know that your plan is that in the end pwm-core is the only implementation of the pwm interface. But right now it is not and on the other hand some SoC implementors might choose that they want to provide their own minimal pwm interface implementation. Furthermore this would allow you to start with pwm-core for one SoC which you have on your desk and where you can properly test things and keep the patches clean from clutter changing all the different archs. Once pwm-core is in a proper shape you or other people can start porting all the different SoC support code to pwm-core. Similar behavior is for example true for the gpio api. There is gpiolib which is the generic implementation which allows having gpio chips outside of the chip. On the other hand there are still archs which choose to have their own gpio api implementation. > >>> pwm_device will be passed to each and every pwm driver that are >> registered as client with pwm core. >>> The list consists of the registered pwm drivers and is to be handled >> by pwm core. >>> Why should each and every pwm driver get to know about the entire pwm >> driver list? >> Declare the list field to be private, by saying that it should only be >> touched by the >> core. Right now you allocate a rather small additional structure for >> each registered >> device. This could be easily be avoided by embedding the list field >> into the >> pwm_device struct. > > The one that is being allocated in register is the pwm_device and this has to. Because each pwm driver will have their own data related to ops, pwm_id. > Also note that there exists an element "data" that points to the pwm device specific information. Hence this allocation is required. > >>>>> + } >>>>> + pwm->pwm_dev = pwm_dev; >>>>> + list_add_tail(&pwm->list, &di->list); >>>>> + up_write(&pwm_list_lock); >>>>> + >>>> I guess you only need to lock the list when accessing the list and >>>> adding the new >>>> pwm_dev. >>> Oops, thanks for pointing out, will implement this in the v2 patch. > Coming back to this, I guess the locking has to be done while traversing the list also, as my present pointer in the list my get over written by the time I add an element to list. Please let me know if I am wrong. > >>>>> +struct pwm_ops { >>>>> + int (*pwm_config)(struct pwm_device *pwm, int duty_ns, int >>>> period_ns); >>>>> + int (*pwm_enable)(struct pwm_device *pwm); >>>>> + int (*pwm_disable)(struct pwm_device *pwm); >>>>> + char *name; >>>>> +}; >>>>> + >>>> Shouldn't name be part of the pwm_device? That would allow the ops >> to >>>> be shared >>>> between different devices. >>> Good catch, the reason being that 2 or more devices can share the >> same ops and get registered to pwm core. >>> But the catch lies while identifying the pwm device while the clients >> are requesting for. >>> The pwm backlight will request the pwm driver by name. This is >> parameter that distinguishes among different pwm devices irrespective >> of same ops or not. >> Yes. And thats why it should go into the pwm_device struct itself. >> >> If an additional ops struct is allocated for each device anyway we >> would be better of >> embedding it directly into the device struct instead of just holding a >> pointer to it. > Yes ops structure will be allocated. But how can we get access to the ops structure of another driver? > And moreover two pwm driver sharing same ops ideally means a single pwm module. If not everything atleast the pwm registers of two different modules changes. So this scenario can never occur. > >>>>> #endif /* __LINUX_PWM_H */ >>>> It might be also a good idea to add a device class for pwm devices. >>> Sure, but can you please explain with an example the use case. >>> >> Well, for one it helps to keep data structured. >> And there would be functions to traverse all devices of a class, so you >> could get rid >> of your "di" list. > Sorry, I didn't get you can you please elaborate more? > Sure. You would create a "struct class" device class for pwm devices. For each registered pwm device there would then be a "struct device" representing the pwm device whithin the linux device tree. This has serveral advantages: For one you can use this for keeping track of the all the pwm devices instead of having your custom list. You can use class_for_each_device and class_find_device instead of traversing your list. This would make the core much simpler and more readable. Also you can use the device structure for refcounting of modules and devices. Right now if a pwm-core driver, like the twl6040, is build as a module you can remove the module while another driver, for example pwm-backlight, is using a pwm device from the pwm-core driver. Then upon accessing the pwm device from the pwm-backlight driver the code would crash, because it would access already freed memory. - Lars > Thanks and Regards, > Arun R Murthy > ------------- ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 1/7] pwm: Add pwm core driver 2010-09-28 21:04 ` [PATCH 1/7] pwm: Add pwm core driver Lars-Peter Clausen @ 2010-09-29 4:49 ` Arun MURTHY 0 siblings, 0 replies; 6+ messages in thread From: Arun MURTHY @ 2010-09-29 4:49 UTC (permalink / raw) To: Lars-Peter Clausen Cc: eric.y.miao@gmail.com, linux@arm.linux.org.uk, Andrew Morton, kernel@pengutronix.de, philipp.zabel@gmail.com, robert.jarzmik@free.fr, Marek Vasut, rpurdie@rpsys.net, Samuel Ortiz, kgene.kim@samsung.com, linux-omap@vger.kernel.org, broonie@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, Linus WALLEIJ, Mattias WALLIN, linux-arm-kernel, linux-mips@linux-mips.org, STEricsson_nomadik_linux > Arun MURTHY wrote: > >>>> Shouldn't PWM_DEVICES select HAVE_PWM? > >>> > >>> No not required, the entire concept is to remove HAVE_PWM and use > >> PWM_CORE. > >> > >> Well in patch 4 you say that PWM_CORE is currently limited to ARM. > >> Furthermore you > >> change the pwm-backlight and pwm-led Kconfig entries to depend on > >> HAVE_PWM || > >> PWM_CORE. Adding a select HAVE_PWM here would make those changes > >> unnecessary. > > HAVE_PWM is retained just because the mips pwm driver is not aligned > with the pwm core driver. > > On mips pwm driver aligning to the pwm core driver HAVE_PWM will be > replaced by PWM_CORE. > > > >> HAVE_PWM should be set, when pwm_* functions are available. When > your > >> pwm-core driver > >> is selected they are available. > > On applying this patch set pwm_* function will be exported in > pwm_core driver and in mips pwm driver. > > Since mips pwm driver is not aligned with the pwm core, HAVE_PWM is > retained and removed in places where pwm drivers register to pwm core > driver. > > pwm_{enable,disable,request,free} are the interface of the pwm api. > Your pwm-core is > one implementation of that interface. A somewhat special though, > because it tries to > be a generic implementation. > There are still other implementations though. For example right now the > mips jz4740 one. > In my opinion HAVE_PWM should be defined if there is a implementation > for the pwm > interface is available. > I know that your plan is that in the end pwm-core is the only > implementation of the > pwm interface. Yes for that reason, I still have retained the HAVE_PWM, once that is also aligned with pwm core, HAVE_PWM will be totally removed. I am in the process of doing the same in this series of patch, but was blocked by mips jz4740 pwm driver. Will do that very soon in near future. > > But right now it is not and on the other hand some SoC implementors > might choose that > they want to provide their own minimal pwm interface implementation. > Furthermore this would allow you to start with pwm-core for one SoC > which you have on > your desk and where you can properly test things and keep the patches > clean from > clutter changing all the different archs. > Once pwm-core is in a proper shape you or other people can start > porting all the > different SoC support code to pwm-core. That's the exact reason for me to come up with this core driver, which has the minimal part and the one that are common in all pwm drivers. Not only common most if not all pwm drivers just make use of only these functions. Moreover I have aligned all existing pwm driver in my patch 4/7 :-) > > Similar behavior is for example true for the gpio api. There is gpiolib > which is the > generic implementation which allows having gpio chips outside of the > chip. On the > other hand there are still archs which choose to have their own gpio > api implementation. > > > > >>> pwm_device will be passed to each and every pwm driver that are > >> registered as client with pwm core. > >>> The list consists of the registered pwm drivers and is to be > handled > >> by pwm core. > >>> Why should each and every pwm driver get to know about the entire > pwm > >> driver list? > >> Declare the list field to be private, by saying that it should only > be > >> touched by the > >> core. Right now you allocate a rather small additional structure for > >> each registered > >> device. This could be easily be avoided by embedding the list field > >> into the > >> pwm_device struct. > > > > The one that is being allocated in register is the pwm_device and > this has to. Because each pwm driver will have their own data related > to ops, pwm_id. > > Also note that there exists an element "data" that points to the pwm > device specific information. Hence this allocation is required. > > > >>>>> + } > >>>>> + pwm->pwm_dev = pwm_dev; > >>>>> + list_add_tail(&pwm->list, &di->list); > >>>>> + up_write(&pwm_list_lock); > >>>>> + > >>>> I guess you only need to lock the list when accessing the list and > >>>> adding the new > >>>> pwm_dev. > >>> Oops, thanks for pointing out, will implement this in the v2 patch. > > Coming back to this, I guess the locking has to be done while > traversing the list also, as my present pointer in the list my get over > written by the time I add an element to list. Please let me know if I > am wrong. > > > >>>>> +struct pwm_ops { > >>>>> + int (*pwm_config)(struct pwm_device *pwm, int duty_ns, int > >>>> period_ns); > >>>>> + int (*pwm_enable)(struct pwm_device *pwm); > >>>>> + int (*pwm_disable)(struct pwm_device *pwm); > >>>>> + char *name; > >>>>> +}; > >>>>> + > >>>> Shouldn't name be part of the pwm_device? That would allow the ops > >> to > >>>> be shared > >>>> between different devices. > >>> Good catch, the reason being that 2 or more devices can share the > >> same ops and get registered to pwm core. > >>> But the catch lies while identifying the pwm device while the > clients > >> are requesting for. > >>> The pwm backlight will request the pwm driver by name. This is > >> parameter that distinguishes among different pwm devices > irrespective > >> of same ops or not. > >> Yes. And thats why it should go into the pwm_device struct itself. > >> > >> If an additional ops struct is allocated for each device anyway we > >> would be better of > >> embedding it directly into the device struct instead of just holding > a > >> pointer to it. > > Yes ops structure will be allocated. But how can we get access to the > ops structure of another driver? > > And moreover two pwm driver sharing same ops ideally means a single > pwm module. If not everything atleast the pwm registers of two > different modules changes. So this scenario can never occur. > > > >>>>> #endif /* __LINUX_PWM_H */ > >>>> It might be also a good idea to add a device class for pwm > devices. > >>> Sure, but can you please explain with an example the use case. > >>> > >> Well, for one it helps to keep data structured. > >> And there would be functions to traverse all devices of a class, so > you > >> could get rid > >> of your "di" list. > > Sorry, I didn't get you can you please elaborate more? > > > Sure. You would create a "struct class" device class for pwm devices. > For each > registered pwm device there would then be a "struct device" > representing the pwm > device whithin the linux device tree. > This has serveral advantages: > For one you can use this for keeping track of the all the pwm devices > instead of > having your custom list. You can use class_for_each_device and > class_find_device > instead of traversing your list. This would make the core much simpler > and more readable. > Also you can use the device structure for refcounting of modules and > devices. Right > now if a pwm-core driver, like the twl6040, is build as a module you > can remove the > module while another driver, for example pwm-backlight, is using a pwm > device from > the pwm-core driver. Then upon accessing the pwm device from the pwm- > backlight driver > the code would crash, because it would access already freed memory. > Can this be taken after this patch is merged? Thanks and Regards, Arun R Murthy ------------ ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/7] PWM core driver for pwm based led and backlight driver @ 2010-09-28 10:35 Arun Murthy 2010-09-28 10:35 ` [PATCH 1/7] pwm: Add pwm core driver Arun Murthy 0 siblings, 1 reply; 6+ messages in thread From: Arun Murthy @ 2010-09-28 10:35 UTC (permalink / raw) To: lars, akpm, kernel, philipp.zabel, robert.jarzmik, marek.vasut, eric.y.miao, rpurdie, sameo, kgene.kim, linux-omap Cc: linux-arm-kernel, linux-kernel, linux-mips, arun.murthy, STEricsson_nomadik_linux The series of patch add a new pwm core driver. Align the existing pwm drivers to make use of the pwm core driver. Arun Murthy (7): pwm: Add pwm core driver backlight:pwm: add an element 'name' to platform data leds: pwm: add a new element 'name' to platform data pwm: Align existing pwm drivers with pwm-core driver platform: Update the pwm based led and backlight platform data pwm: move existing pwm driver to drivers/pwm pwm: Modify backlight and led Kconfig aligning to pwm core arch/arm/mach-pxa/cm-x300.c | 1 + arch/arm/mach-pxa/colibri-pxa270-income.c | 1 + arch/arm/mach-pxa/ezx.c | 1 + arch/arm/mach-pxa/hx4700.c | 1 + arch/arm/mach-pxa/lpd270.c | 1 + arch/arm/mach-pxa/magician.c | 1 + arch/arm/mach-pxa/mainstone.c | 1 + arch/arm/mach-pxa/mioa701.c | 1 + arch/arm/mach-pxa/palm27x.c | 1 + arch/arm/mach-pxa/palmtc.c | 1 + arch/arm/mach-pxa/palmte2.c | 1 + arch/arm/mach-pxa/pcm990-baseboard.c | 1 + arch/arm/mach-pxa/raumfeld.c | 1 + arch/arm/mach-pxa/tavorevb.c | 2 + arch/arm/mach-pxa/viper.c | 1 + arch/arm/mach-pxa/z2.c | 2 + arch/arm/mach-pxa/zylonite.c | 1 + arch/arm/mach-s3c2410/mach-h1940.c | 1 + arch/arm/mach-s3c2440/mach-rx1950.c | 1 + arch/arm/mach-s3c64xx/mach-hmt.c | 1 + arch/arm/mach-s3c64xx/mach-smartq.c | 1 + arch/arm/plat-mxc/pwm.c | 166 +++++++++------------ arch/arm/plat-pxa/pwm.c | 210 ++++++++++++-------------- arch/arm/plat-samsung/pwm.c | 235 +++++++++++++---------------- arch/mips/jz4740/pwm.c | 2 +- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/leds/Kconfig | 2 +- drivers/leds/leds-pwm.c | 4 +- drivers/mfd/Kconfig | 9 - drivers/mfd/Makefile | 1 - drivers/mfd/twl-core.c | 13 ++ drivers/mfd/twl6030-pwm.c | 163 -------------------- drivers/misc/Kconfig | 9 - drivers/misc/Makefile | 1 - drivers/misc/ab8500-pwm.c | 168 -------------------- drivers/pwm/Kconfig | 33 ++++ drivers/pwm/Makefile | 4 + drivers/pwm/pwm-ab8500.c | 157 +++++++++++++++++++ drivers/pwm/pwm-core.c | 124 +++++++++++++++ drivers/pwm/pwm-twl6040.c | 196 ++++++++++++++++++++++++ drivers/video/backlight/Kconfig | 2 +- drivers/video/backlight/pwm_bl.c | 4 +- include/linux/leds_pwm.h | 1 + include/linux/pwm.h | 29 ++++- include/linux/pwm_backlight.h | 1 + 46 files changed, 864 insertions(+), 696 deletions(-) delete mode 100644 drivers/mfd/twl6030-pwm.c delete mode 100644 drivers/misc/ab8500-pwm.c create mode 100644 drivers/pwm/Kconfig create mode 100644 drivers/pwm/Makefile create mode 100644 drivers/pwm/pwm-ab8500.c create mode 100644 drivers/pwm/pwm-core.c create mode 100644 drivers/pwm/pwm-twl6040.c -- 1.7.2.dirty ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/7] pwm: Add pwm core driver 2010-09-28 10:35 [PATCH 0/7] PWM core driver for pwm based led and backlight driver Arun Murthy @ 2010-09-28 10:35 ` Arun Murthy 2010-09-28 12:53 ` Hemanth V 0 siblings, 1 reply; 6+ messages in thread From: Arun Murthy @ 2010-09-28 10:35 UTC (permalink / raw) To: lars, akpm, kernel, philipp.zabel, robert.jarzmik, marek.vasut, eric.y.miao, rpurdie, sameo, kgene.kim, linux-omap Cc: linux-arm-kernel, linux-kernel, linux-mips, arun.murthy, STEricsson_nomadik_linux The existing pwm based led and backlight driver makes use of the pwm(include/linux/pwm.h). So all the board specific pwm drivers will be exposing the same set of function name as in include/linux/pwm.h. As a result build fails in case of multi soc environments where each soc has a pwm device in it. In order to overcome this issue all the pwm drivers must register to some core pwm driver with function pointers for pwm operations (i.e pwm_config, pwm_enable, pwm_disable). The clients of pwm device will have to call pwm_request, wherein they will get the pointer to struct pwm_ops. This structure include function pointers for pwm_config, pwm_enable and pwm_disable. Signed-off-by: Arun Murthy <arun.murthy@stericsson.com> Acked-by: Linus Walleij <linus.walleij@stericsson.com> --- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/pwm/Kconfig | 16 ++++++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-core.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pwm.h | 12 ++++- 6 files changed, 160 insertions(+), 1 deletions(-) create mode 100644 drivers/pwm/Kconfig create mode 100644 drivers/pwm/Makefile create mode 100644 drivers/pwm/pwm-core.c diff --git a/drivers/Kconfig b/drivers/Kconfig index a2b902f..e042f27 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -111,4 +111,6 @@ source "drivers/xen/Kconfig" source "drivers/staging/Kconfig" source "drivers/platform/Kconfig" + +source "drivers/pwm/Kconfig" endmenu diff --git a/drivers/Makefile b/drivers/Makefile index 4ca727d..0061ec4 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -116,3 +116,4 @@ obj-$(CONFIG_STAGING) += staging/ obj-y += platform/ obj-y += ieee802154/ obj-y += vbus/ +obj-$(CONFIG_PWM_DEVICES) += pwm/ diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig new file mode 100644 index 0000000..5d10106 --- /dev/null +++ b/drivers/pwm/Kconfig @@ -0,0 +1,16 @@ +# +# PWM devices +# + +menuconfig PWM_DEVICES + bool "PWM devices" + default y + ---help--- + Say Y here to get to see options for device drivers from various + different categories. This option alone does not add any kernel code. + + If you say N, all options in this submenu will be skipped and disabled. + +if PWM_DEVICES + +endif # PWM_DEVICES diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile new file mode 100644 index 0000000..552f969 --- /dev/null +++ b/drivers/pwm/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_PWM_DEVICES) += pwm-core.o diff --git a/drivers/pwm/pwm-core.c b/drivers/pwm/pwm-core.c new file mode 100644 index 0000000..b84027a --- /dev/null +++ b/drivers/pwm/pwm-core.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) ST-Ericsson SA 2010 + * + * License Terms: GNU General Public License v2 + * Author: Arun R Murthy <arun.murthy@stericsson.com> + */ +#include <linux/init.h> +#include <linux/device.h> +#include <linux/slab.h> +#include <linux/rwsem.h> +#include <linux/err.h> +#include <linux/pwm.h> + +struct pwm_device { + struct pwm_ops *pops; + int pwm_id; +}; + +struct pwm_dev_info { + struct pwm_device *pwm_dev; + struct list_head list; +}; +static struct pwm_dev_info *di; + +DECLARE_RWSEM(pwm_list_lock); + +void __deprecated pwm_free(struct pwm_device *pwm) +{ +} + +int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) +{ + return pwm->pops->pwm_config(pwm, duty_ns, period_ns); +} +EXPORT_SYMBOL(pwm_config); + +int pwm_enable(struct pwm_device *pwm) +{ + return pwm->pops->pwm_enable(pwm); +} +EXPORT_SYMBOL(pwm_enable); + +void pwm_disable(struct pwm_device *pwm) +{ + pwm->pops->pwm_disable(pwm); +} +EXPORT_SYMBOL(pwm_disable); + +int pwm_device_register(struct pwm_device *pwm_dev) +{ + struct pwm_dev_info *pwm; + + down_write(&pwm_list_lock); + pwm = kzalloc(sizeof(struct pwm_dev_info), GFP_KERNEL); + if (!pwm) { + up_write(&pwm_list_lock); + return -ENOMEM; + } + pwm->pwm_dev = pwm_dev; + list_add_tail(&pwm->list, &di->list); + up_write(&pwm_list_lock); + + return 0; +} +EXPORT_SYMBOL(pwm_device_register); + +int pwm_device_unregister(struct pwm_device *pwm_dev) +{ + struct pwm_dev_info *tmp; + struct list_head *pos, *tmp_lst; + + down_write(&pwm_list_lock); + list_for_each_safe(pos, tmp_lst, &di->list) { + tmp = list_entry(pos, struct pwm_dev_info, list); + if (tmp->pwm_dev == pwm_dev) { + list_del(pos); + kfree(tmp); + up_write(&pwm_list_lock); + return 0; + } + } + up_write(&pwm_list_lock); + return -ENOENT; +} +EXPORT_SYMBOL(pwm_device_unregister); + +struct pwm_device *pwm_request(int pwm_id, const char *name) +{ + struct pwm_dev_info *pwm; + struct list_head *pos; + + down_read(&pwm_list_lock); + list_for_each(pos, &di->list) { + pwm = list_entry(pos, struct pwm_dev_info, list); + if ((!strcmp(pwm->pwm_dev->pops->name, name)) && + (pwm->pwm_dev->pwm_id == pwm_id)) { + up_read(&pwm_list_lock); + return pwm->pwm_dev; + } + } + up_read(&pwm_list_lock); + return ERR_PTR(-ENOENT); +} +EXPORT_SYMBOL(pwm_request); + +static int __init pwm_init(void) +{ + struct pwm_dev_info *pwm; + + pwm = kzalloc(sizeof(struct pwm_dev_info), GFP_KERNEL); + if (!pwm) + return -ENOMEM; + INIT_LIST_HEAD(&pwm->list); + di = pwm; + return 0; +} + +static void __exit pwm_exit(void) +{ + kfree(di); +} + +subsys_initcall(pwm_init); +module_exit(pwm_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Arun R Murthy"); +MODULE_ALIAS("core:pwm"); +MODULE_DESCRIPTION("Core pwm driver"); diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 7c77575..6e7da1f 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -3,6 +3,13 @@ struct pwm_device; +struct pwm_ops { + int (*pwm_config)(struct pwm_device *pwm, int duty_ns, int period_ns); + int (*pwm_enable)(struct pwm_device *pwm); + int (*pwm_disable)(struct pwm_device *pwm); + char *name; +}; + /* * pwm_request - request a PWM device */ @@ -11,7 +18,7 @@ struct pwm_device *pwm_request(int pwm_id, const char *label); /* * pwm_free - free a PWM device */ -void pwm_free(struct pwm_device *pwm); +void __deprecated pwm_free(struct pwm_device *pwm); /* * pwm_config - change a PWM device configuration @@ -28,4 +35,7 @@ int pwm_enable(struct pwm_device *pwm); */ void pwm_disable(struct pwm_device *pwm); +int pwm_device_register(struct pwm_device *pwm_dev); +int pwm_device_unregister(struct pwm_device *pwm_dev); + #endif /* __LINUX_PWM_H */ -- 1.7.2.dirty ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/7] pwm: Add pwm core driver 2010-09-28 10:35 ` [PATCH 1/7] pwm: Add pwm core driver Arun Murthy @ 2010-09-28 12:53 ` Hemanth V 2010-09-28 13:06 ` Samuel Ortiz 0 siblings, 1 reply; 6+ messages in thread From: Hemanth V @ 2010-09-28 12:53 UTC (permalink / raw) To: Arun Murthy, lars, Andrew Morton, kernel, philipp.zabel, robert.jarzmik, marek.vasut, eric.y.miao, rpurdie, sameo, kgene.kim, linux-omap Cc: linux-arm-kernel, linux-kernel, linux-mips, Arun MURTHY, STEricsson_nomadik_linux ----- Original Message ----- From: "Arun Murthy" <arun.murthy@stericsson.com> > The existing pwm based led and backlight driver makes use of the > pwm(include/linux/pwm.h). So all the board specific pwm drivers will > be exposing the same set of function name as in include/linux/pwm.h. > As a result build fails in case of multi soc environments where each soc > has a pwm device in it. This seems very specific to ST environment, looking at the driver list from ( [PATCH 4/7] pwm: Align existing pwm drivers with pwm-core ) it seems most multi SOC environments might support PWM in either one of the SOC. arch/arm/plat-mxc/pwm.c arch/arm/plat-pxa/pwm.c arch/arm/plat-samsung/pwm.c arch/mips/jz4740/pwm.c drivers/mfd/twl6030-pwm.c Unless people have examples of other SOCs which might use this, the better approach might be to go for a custom driver rather than changing the framework. Thanks Hemanth ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/7] pwm: Add pwm core driver 2010-09-28 12:53 ` Hemanth V @ 2010-09-28 13:06 ` Samuel Ortiz 2010-09-28 13:35 ` Felipe Balbi 0 siblings, 1 reply; 6+ messages in thread From: Samuel Ortiz @ 2010-09-28 13:06 UTC (permalink / raw) To: Hemanth V Cc: Arun Murthy, lars, Andrew Morton, kernel, philipp.zabel, robert.jarzmik, marek.vasut, eric.y.miao, rpurdie, kgene.kim, linux-omap, linux-arm-kernel, linux-kernel, linux-mips, STEricsson_nomadik_linux On Tue, Sep 28, 2010 at 06:23:24PM +0530, Hemanth V wrote: > ----- Original Message ----- From: "Arun Murthy" > <arun.murthy@stericsson.com> > > > >The existing pwm based led and backlight driver makes use of the > >pwm(include/linux/pwm.h). So all the board specific pwm drivers will > >be exposing the same set of function name as in include/linux/pwm.h. > >As a result build fails in case of multi soc environments where each soc > >has a pwm device in it. > > This seems very specific to ST environment, No it's not. It's an issue Arun has hit while enabling one of the ST MFD chip, but he's tackling a generic issue. > looking at the driver list from > ( [PATCH 4/7] pwm: Align existing pwm drivers with pwm-core ) it seems > most multi SOC environments might support PWM in either one of the SOC. > > arch/arm/plat-mxc/pwm.c > arch/arm/plat-pxa/pwm.c > arch/arm/plat-samsung/pwm.c > arch/mips/jz4740/pwm.c > drivers/mfd/twl6030-pwm.c > > Unless people have examples of other SOCs which might use this, > the better approach might be to go for a custom driver rather than changing > the framework. I wouldn't call the current pwm code a framework. It's a bunch of header definitions that happens to work in the specific case of 1 pwm per sub architecture. What Arun is proposing is an actual framework. And it seems to be clean and simple enough. Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/7] pwm: Add pwm core driver 2010-09-28 13:06 ` Samuel Ortiz @ 2010-09-28 13:35 ` Felipe Balbi 0 siblings, 0 replies; 6+ messages in thread From: Felipe Balbi @ 2010-09-28 13:35 UTC (permalink / raw) To: Samuel Ortiz Cc: V, Hemanth, Arun Murthy, lars@metafoo.de, Andrew Morton, kernel@pengutronix.de, philipp.zabel@gmail.com, robert.jarzmik@free.fr, marek.vasut@gmail.com, eric.y.miao@gmail.com, rpurdie@rpsys.net, kgene.kim@samsung.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org, STEricsson_nomadik_linux@list.st.com On Tue, Sep 28, 2010 at 08:06:11AM -0500, Samuel Ortiz wrote: >On Tue, Sep 28, 2010 at 06:23:24PM +0530, Hemanth V wrote: >> ----- Original Message ----- From: "Arun Murthy" >> <arun.murthy@stericsson.com> >> >> >> >The existing pwm based led and backlight driver makes use of the >> >pwm(include/linux/pwm.h). So all the board specific pwm drivers will >> >be exposing the same set of function name as in include/linux/pwm.h. >> >As a result build fails in case of multi soc environments where each soc >> >has a pwm device in it. >> >> This seems very specific to ST environment, >No it's not. It's an issue Arun has hit while enabling one of the ST MFD chip, >but he's tackling a generic issue. > >> looking at the driver list from >> ( [PATCH 4/7] pwm: Align existing pwm drivers with pwm-core ) it seems >> most multi SOC environments might support PWM in either one of the SOC. >> >> arch/arm/plat-mxc/pwm.c >> arch/arm/plat-pxa/pwm.c >> arch/arm/plat-samsung/pwm.c >> arch/mips/jz4740/pwm.c >> drivers/mfd/twl6030-pwm.c >> >> Unless people have examples of other SOCs which might use this, >> the better approach might be to go for a custom driver rather than changing >> the framework. >I wouldn't call the current pwm code a framework. It's a bunch of header >definitions that happens to work in the specific case of 1 pwm per >sub architecture. >What Arun is proposing is an actual framework. And it seems to be clean and >simple enough. FWIW, I agree with you Sam. Sooner or later, this will hit other SoCs. -- balbi ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-09-29 4:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1285659648-21409-1-git-send-email-arun.murthy@stericsson.com>
[not found] ` <1285659648-21409-2-git-send-email-arun.murthy@stericsson.com>
[not found] ` <4CA1AD2B.8000905@metafoo.de>
[not found] ` <F45880696056844FA6A73F415B568C69532DC2FB6B@EXDCVYMBSTM006.EQ1STM.local>
[not found] ` <4CA1BC16.3020702@metafoo.de>
[not found] ` <F45880696056844FA6A73F415B568C69532DC2FC60@EXDCVYMBSTM006.EQ1STM.local>
2010-09-28 21:04 ` [PATCH 1/7] pwm: Add pwm core driver Lars-Peter Clausen
2010-09-29 4:49 ` Arun MURTHY
2010-09-28 10:35 [PATCH 0/7] PWM core driver for pwm based led and backlight driver Arun Murthy
2010-09-28 10:35 ` [PATCH 1/7] pwm: Add pwm core driver Arun Murthy
2010-09-28 12:53 ` Hemanth V
2010-09-28 13:06 ` Samuel Ortiz
2010-09-28 13:35 ` Felipe Balbi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox