clk: add LP8788 clock driver
Subsystems (2)
PATCH v2 1/1 clk: add LP8788 clock driver
LP8788 PMU consists of regulator, battery charger, RTC, ADC, backlight driver and current sinks.
Here is additional driver, clock.
* Clock source
LP8788 clock is generated by two clock source.
One is internal oscillator. The other is attached external crystal oscillator. LP8788 provides automatic clock source selection through the I2C register. This operation is executed in 'prepare' of common clock driver architecture.
* Clock rate
LP8788 generates a fixed 32768Hz clock which is used for the system.
* Supported operations
.prepare: Before the clock is enabled, automatic clock source selection is done
by register access.
.unprepare: No register for disable or remove the clock source, so do nothing. .recalc_rate: Fixed clock rate, 32.768KHz.
* clk_register_fixed_rate() vs devm_clk_register() and clkdev_add() Fixed clock driver can be created by common clock helper function but but LP8788 should be built as a module.
Using devm_clk_register() and clkdev_add() is more appropriate method to implement LP8788 clock driver.
Patch v2.
(a) Remove unnecessary 'is_enabled()' operation code.
(b) Add CLK_IGNORE_UNUSED flag.
(c) Add clock device detection code : lp8788_is_clk_device_ready() If the device is not ready, return as -ENODEV on loading the driver.
Patch v1.
Initial patch
--- drivers/clk/Kconfig | 7 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-lp8788.c | 160 ++++++++++++++++++++++++++++++++++++++++++++ drivers/mfd/lp8788.c | 2 + include/linux/mfd/lp8788.h | 1 + 5 files changed, 171 insertions(+) create mode 100644 drivers/clk/clk-lp8788.c
drivers/clk/Kconfig +7 -0
@@ -71,6 +71,13 @@ config COMMON_CLK_AXI_CLKGEN Support for the Analog Devices axi-clkgen pcore clock generator for Xilinx FPGAs. It is commonly used in Analog Devices' reference designs. +config CLK_LP8788 + tristate "Clock driver for TI LP8788 PMU" + depends on MFD_LP8788 + ---help--- + Supports the clock subsystem of TI LP8788. It generates the 32KHz + clock output. + endmenu source "drivers/clk/mvebu/Kconfig"
drivers/clk/Makefile +1 -0
@@ -37,3 +37,4 @@ obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o +obj-$(CONFIG_CLK_LP8788) += clk-lp8788.o
drivers/clk/clk-lp8788.c new file +160 -0
160 lines not on this page · raw message
drivers/mfd/lp8788.c +2 -0
@@ -72,6 +72,8 @@ static struct resource rtc_irqs[] = { };static struct mfd_cell lp8788_devs[] = { +MFD_DEV_SIMPLE (CLK ), +/* 4 bucks */ MFD_DEV_WITH_ID (BUCK ,1 ),MFD_DEV_WITH_ID (BUCK ,2 ),
include/linux/mfd/lp8788.h +1 -0
@@ -28,6 +28,7 @@#define LP8788_DEV_VIBRATOR "lp8788-vibrator"#define LP8788_DEV_KEYLED "lp8788-keyled"#define LP8788_DEV_ADC "lp8788-adc" +#define LP8788_DEV_CLK "lp8788-clk"#define LP8788_NUM_BUCKS 4#define LP8788_NUM_DLDOS 12
Signature · 5 lines
1.7.9.5 Best Regards, Milo
PATCH v2 1/1 clk: add LP8788 clock driver
Quoting Kim, Milo (2013-04-03 18:34:37)
Quoted 9 lines
Patch v2.
(a) Remove unnecessary 'is_enabled()' operation code.
(b) AddCLK_IGNORE_UNUSEDflag.
(c) Add clock device detection code :lp8788_is_clk_device_ready()If the device is not ready, return as-ENODEVon loading the driver.Patch v1.
Initial patch
It's better to put the above changelog stuff below in the scratchpad area ...
Quoted 2 lines
Signed-off-by Milo(Woogyom) Kim <[email protected]>---
... here.
Quoted 12 lines
drivers/clk/Kconfig | 7 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-lp8788.c | 160 ++++++++++++++++++++++++++++++++++++++++++++ drivers/mfd/lp8788.c | 2 + include/linux/mfd/lp8788.h | 1 + 5 files changed, 171 insertions(+) create mode 100644 drivers/clk/clk-lp8788.cdrivers/clk/clk-lp8788.c new file +4
-0+static int lp8788_clk_probe (struct platform_device *pdev) +{ +struct lp8788 *lp =dev_get_drvdata (pdev->dev.parent); +struct lp8788_clk *pclk;
drivers/clk/clk-lp8788.c line 123
Quoted 10 lines
drivers/clk/clk-lp8788.c new file +10
-0+ + pclk =devm_kzalloc (&pdev->dev,sizeof (struct lp8788_clk ),GFP_KERNEL ); +if (!pclk) +return -ENOMEM ; + + pclk->lp = lp; +platform_set_drvdata (pdev, pclk); + +if (!lp8788_is_clk_device_ready (pclk)) +return -ENODEV ;
Would EPROBE_DEFER be better?
Quoted 55 lines
drivers/clk/clk-lp8788.c new file +37
-0+ +return lp8788_clk_register (&pdev->dev, pclk); +} + +static int lp8788_clk_remove (struct platform_device *pdev) +{ +struct lp8788_clk *pclk =platform_get_drvdata (pdev); + +lp8788_clk_unregister (pclk); +return 0 ; +} + +static struct platform_driver lp8788_clk_driver = { + .probe = lp8788_clk_probe, + .remove = lp8788_clk_remove, + .driver = { + .name =LP8788_DEV_CLK , + .owner =THIS_MODULE , + }, +}; + +static int __init lp8788_clk_init (void ) +{ +return platform_driver_register (&lp8788_clk_driver); +} +subsys_initcall (lp8788_clk_init); + +static void __exit lp8788_clk_exit(void) +{ +platform_driver_unregister (&lp8788_clk_driver); +} +module_exit (lp8788_clk_exit); + +MODULE_DESCRIPTION ("TI LP8788 Clock Driver" ); +MODULE_AUTHOR ("Milo Kim" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:lp8788-clk" );drivers/mfd/lp8788.c +2
-0@@ -72,6 +72,8 @@ static struct resource rtc_irqs[] = { };static struct mfd_cell lp8788_devs[] = { +MFD_DEV_SIMPLE (CLK ), +/* 4 bucks */ MFD_DEV_WITH_ID (BUCK ,1 ),MFD_DEV_WITH_ID (BUCK ,2 ),include/linux/mfd/lp8788.h +0
-0
include/linux/mfd/lp8788.h line 34
Quoted 7 lines
include/linux/mfd/lp8788.h +1
-0@@ -28,6 +28,7 @@#define LP8788_DEV_VIBRATOR "lp8788-vibrator"#define LP8788_DEV_KEYLED "lp8788-keyled"#define LP8788_DEV_ADC "lp8788-adc" +#define LP8788_DEV_CLK "lp8788-clk"#define LP8788_NUM_BUCKS 4#define LP8788_NUM_DLDOS 12
I guess the above two hunks need Samuel's ACK.
Regards,
Mike
Quoted 6 lines
Signature · 5 lines
1.7.9.5 Best Regards, Milo
Hi Milo,
Quoted 10 lines · Milo
Patch v2.
(a) Remove unnecessary 'is_enabled()' operation code.
(b) AddCLK_IGNORE_UNUSEDflag.
(c) Add clock device detection code :lp8788_is_clk_device_ready()If the device is not ready, return as-ENODEVon loading the driver.Patch v1.
Initial patchSigned-off-by Milo(Woogyom) Kim <[email protected]>
Quoted 8 lines
--- drivers/clk/Kconfig | 7 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-lp8788.c | 160 ++++++++++++++++++++++++++++++++++++++++++++ drivers/mfd/lp8788.c | 2 + include/linux/mfd/lp8788.h | 1 + 5 files changed, 171 insertions(+) create mode 100644 drivers/clk/clk-lp8788.c
For the MFD part:
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/