2019-11-07 10:33:36

by Rajan Vaja

[permalink] [raw]
Subject: [PATCH] drivers: clocksource: Use ttc driver as platform driver

Currently TTC driver is TIMER_OF_DECLARE type driver. Because of
that, TTC driver may be initialized before other clock drivers. If
TTC driver is dependent on that clock driver then initialization of
TTC driver will failed.

So use TTC driver as platform driver instead of using
TIMER_OF_DECLARE.

Signed-off-by: Rajan Vaja <[email protected]>
---
drivers/clocksource/timer-cadence-ttc.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
index 88fe2e9..38858e1 100644
--- a/drivers/clocksource/timer-cadence-ttc.c
+++ b/drivers/clocksource/timer-cadence-ttc.c
@@ -15,6 +15,8 @@
#include <linux/of_irq.h>
#include <linux/slab.h>
#include <linux/sched_clock.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>

/*
* This driver configures the 2 16/32-bit count-up timers as follows:
@@ -464,13 +466,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
return 0;
}

-/**
- * ttc_timer_init - Initialize the timer
- *
- * Initializes the timer hardware and register the clock source and clock event
- * timers with Linux kernal timer framework
- */
-static int __init ttc_timer_init(struct device_node *timer)
+static int __init ttc_timer_probe(struct platform_device *pdev)
{
unsigned int irq;
void __iomem *timer_baseaddr;
@@ -478,6 +474,7 @@ static int __init ttc_timer_init(struct device_node *timer)
static int initialized;
int clksel, ret;
u32 timer_width = 16;
+ struct device_node *timer = pdev->dev.of_node;

if (initialized)
return 0;
@@ -532,4 +529,17 @@ static int __init ttc_timer_init(struct device_node *timer)
return 0;
}

-TIMER_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init);
+static const struct of_device_id ttc_timer_of_match[] = {
+ {.compatible = "cdns,ttc"},
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, ttc_timer_of_match);
+
+static struct platform_driver ttc_timer_driver = {
+ .driver = {
+ .name = "cdns_ttc_timer",
+ .of_match_table = ttc_timer_of_match,
+ },
+};
+builtin_platform_driver_probe(ttc_timer_driver, ttc_timer_probe);
--
2.7.4


2019-11-07 10:37:44

by Rajan Vaja

[permalink] [raw]
Subject: RE: [PATCH] drivers: clocksource: Use ttc driver as platform driver

Please discard this email as there is a typo in email address ([email protected] -> [email protected]). I am sending new email.

Thanks,
Rajan

> -----Original Message-----
> From: Rajan Vaja <[email protected]>
> Sent: 07 November 2019 02:31
> To: [email protected]; [email protected]; [email protected]
> Cc: [email protected]; [email protected]; Rajan
> Vaja <[email protected]>
> Subject: [PATCH] drivers: clocksource: Use ttc driver as platform driver
>
> Currently TTC driver is TIMER_OF_DECLARE type driver. Because of
> that, TTC driver may be initialized before other clock drivers. If
> TTC driver is dependent on that clock driver then initialization of
> TTC driver will failed.
>
> So use TTC driver as platform driver instead of using
> TIMER_OF_DECLARE.
>
> Signed-off-by: Rajan Vaja <[email protected]>
> ---
> drivers/clocksource/timer-cadence-ttc.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-
> cadence-ttc.c
> index 88fe2e9..38858e1 100644
> --- a/drivers/clocksource/timer-cadence-ttc.c
> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -15,6 +15,8 @@
> #include <linux/of_irq.h>
> #include <linux/slab.h>
> #include <linux/sched_clock.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
>
> /*
> * This driver configures the 2 16/32-bit count-up timers as follows:
> @@ -464,13 +466,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
> return 0;
> }
>
> -/**
> - * ttc_timer_init - Initialize the timer
> - *
> - * Initializes the timer hardware and register the clock source and clock event
> - * timers with Linux kernal timer framework
> - */
> -static int __init ttc_timer_init(struct device_node *timer)
> +static int __init ttc_timer_probe(struct platform_device *pdev)
> {
> unsigned int irq;
> void __iomem *timer_baseaddr;
> @@ -478,6 +474,7 @@ static int __init ttc_timer_init(struct device_node *timer)
> static int initialized;
> int clksel, ret;
> u32 timer_width = 16;
> + struct device_node *timer = pdev->dev.of_node;
>
> if (initialized)
> return 0;
> @@ -532,4 +529,17 @@ static int __init ttc_timer_init(struct device_node *timer)
> return 0;
> }
>
> -TIMER_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init);
> +static const struct of_device_id ttc_timer_of_match[] = {
> + {.compatible = "cdns,ttc"},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, ttc_timer_of_match);
> +
> +static struct platform_driver ttc_timer_driver = {
> + .driver = {
> + .name = "cdns_ttc_timer",
> + .of_match_table = ttc_timer_of_match,
> + },
> +};
> +builtin_platform_driver_probe(ttc_timer_driver, ttc_timer_probe);
> --
> 2.7.4

2019-11-26 12:45:25

by Rajan Vaja

[permalink] [raw]
Subject: RE: [PATCH] drivers: clocksource: Use ttc driver as platform driver

Request for review.

Thanks,
Rajan

> -----Original Message-----
> From: Rajan Vaja <[email protected]>
> Sent: 07 November 2019 04:01 PM
> To: [email protected]; [email protected]; [email protected]
> Cc: [email protected]; [email protected]; Rajan Vaja
> <[email protected]>
> Subject: [PATCH] drivers: clocksource: Use ttc driver as platform driver
>
> Currently TTC driver is TIMER_OF_DECLARE type driver. Because of
> that, TTC driver may be initialized before other clock drivers. If
> TTC driver is dependent on that clock driver then initialization of
> TTC driver will failed.
>
> So use TTC driver as platform driver instead of using
> TIMER_OF_DECLARE.
>
> Signed-off-by: Rajan Vaja <[email protected]>
> ---
> drivers/clocksource/timer-cadence-ttc.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-
> cadence-ttc.c
> index 88fe2e9..38858e1 100644
> --- a/drivers/clocksource/timer-cadence-ttc.c
> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -15,6 +15,8 @@
> #include <linux/of_irq.h>
> #include <linux/slab.h>
> #include <linux/sched_clock.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
>
> /*
> * This driver configures the 2 16/32-bit count-up timers as follows:
> @@ -464,13 +466,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
> return 0;
> }
>
> -/**
> - * ttc_timer_init - Initialize the timer
> - *
> - * Initializes the timer hardware and register the clock source and clock event
> - * timers with Linux kernal timer framework
> - */
> -static int __init ttc_timer_init(struct device_node *timer)
> +static int __init ttc_timer_probe(struct platform_device *pdev)
> {
> unsigned int irq;
> void __iomem *timer_baseaddr;
> @@ -478,6 +474,7 @@ static int __init ttc_timer_init(struct device_node *timer)
> static int initialized;
> int clksel, ret;
> u32 timer_width = 16;
> + struct device_node *timer = pdev->dev.of_node;
>
> if (initialized)
> return 0;
> @@ -532,4 +529,17 @@ static int __init ttc_timer_init(struct device_node *timer)
> return 0;
> }
>
> -TIMER_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init);
> +static const struct of_device_id ttc_timer_of_match[] = {
> + {.compatible = "cdns,ttc"},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, ttc_timer_of_match);
> +
> +static struct platform_driver ttc_timer_driver = {
> + .driver = {
> + .name = "cdns_ttc_timer",
> + .of_match_table = ttc_timer_of_match,
> + },
> +};
> +builtin_platform_driver_probe(ttc_timer_driver, ttc_timer_probe);
> --
> 2.7.4

2019-11-26 12:48:29

by Rajan Vaja

[permalink] [raw]
Subject: RE: [PATCH] drivers: clocksource: Use ttc driver as platform driver

Please ignore this request.

Thanks,
Rajan

> -----Original Message-----
> From: Rajan Vaja
> Sent: 26 November 2019 05:06 PM
> To: Rajan Vaja <[email protected]>; [email protected];
> [email protected]; [email protected]
> Cc: [email protected]; [email protected]
> Subject: RE: [PATCH] drivers: clocksource: Use ttc driver as platform driver
>
> Request for review.
>
> Thanks,
> Rajan
>
> > -----Original Message-----
> > From: Rajan Vaja <[email protected]>
> > Sent: 07 November 2019 04:01 PM
> > To: [email protected]; [email protected]; [email protected]
> > Cc: [email protected]; [email protected]; Rajan
> Vaja
> > <[email protected]>
> > Subject: [PATCH] drivers: clocksource: Use ttc driver as platform driver
> >
> > Currently TTC driver is TIMER_OF_DECLARE type driver. Because of
> > that, TTC driver may be initialized before other clock drivers. If
> > TTC driver is dependent on that clock driver then initialization of
> > TTC driver will failed.
> >
> > So use TTC driver as platform driver instead of using
> > TIMER_OF_DECLARE.
> >
> > Signed-off-by: Rajan Vaja <[email protected]>
> > ---
> > drivers/clocksource/timer-cadence-ttc.c | 26 ++++++++++++++++++--------
> > 1 file changed, 18 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-
> > cadence-ttc.c
> > index 88fe2e9..38858e1 100644
> > --- a/drivers/clocksource/timer-cadence-ttc.c
> > +++ b/drivers/clocksource/timer-cadence-ttc.c
> > @@ -15,6 +15,8 @@
> > #include <linux/of_irq.h>
> > #include <linux/slab.h>
> > #include <linux/sched_clock.h>
> > +#include <linux/module.h>
> > +#include <linux/of_platform.h>
> >
> > /*
> > * This driver configures the 2 16/32-bit count-up timers as follows:
> > @@ -464,13 +466,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
> > return 0;
> > }
> >
> > -/**
> > - * ttc_timer_init - Initialize the timer
> > - *
> > - * Initializes the timer hardware and register the clock source and clock event
> > - * timers with Linux kernal timer framework
> > - */
> > -static int __init ttc_timer_init(struct device_node *timer)
> > +static int __init ttc_timer_probe(struct platform_device *pdev)
> > {
> > unsigned int irq;
> > void __iomem *timer_baseaddr;
> > @@ -478,6 +474,7 @@ static int __init ttc_timer_init(struct device_node *timer)
> > static int initialized;
> > int clksel, ret;
> > u32 timer_width = 16;
> > + struct device_node *timer = pdev->dev.of_node;
> >
> > if (initialized)
> > return 0;
> > @@ -532,4 +529,17 @@ static int __init ttc_timer_init(struct device_node
> *timer)
> > return 0;
> > }
> >
> > -TIMER_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init);
> > +static const struct of_device_id ttc_timer_of_match[] = {
> > + {.compatible = "cdns,ttc"},
> > + {},
> > +};
> > +
> > +MODULE_DEVICE_TABLE(of, ttc_timer_of_match);
> > +
> > +static struct platform_driver ttc_timer_driver = {
> > + .driver = {
> > + .name = "cdns_ttc_timer",
> > + .of_match_table = ttc_timer_of_match,
> > + },
> > +};
> > +builtin_platform_driver_probe(ttc_timer_driver, ttc_timer_probe);
> > --
> > 2.7.4