diff options
| author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2016-09-09 07:13:48 -0400 |
|---|---|---|
| committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2016-09-12 01:28:45 -0400 |
| commit | a17686c462441a01973c18c4c47986a320a5ebe3 (patch) | |
| tree | 9c6ec47f432f9686395f0180f092632955b5cf38 /drivers/clocksource | |
| parent | e2a2d38501cb759333342d97442b3742830752ca (diff) | |
clocksource/drivers/timer-atmel-pit: Drop at91sam926x_pit_common_init
Merge at91sam926x_pit_common_init in at91sam926x_pit_dt_init as this is the
only initialization method now.
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource')
| -rw-r--r-- | drivers/clocksource/timer-atmel-pit.c | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c index 7f0f5b26d8c5..da7e6d4eef4d 100644 --- a/drivers/clocksource/timer-atmel-pit.c +++ b/drivers/clocksource/timer-atmel-pit.c | |||
| @@ -177,11 +177,41 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id) | |||
| 177 | /* | 177 | /* |
| 178 | * Set up both clocksource and clockevent support. | 178 | * Set up both clocksource and clockevent support. |
| 179 | */ | 179 | */ |
| 180 | static int __init at91sam926x_pit_common_init(struct pit_data *data) | 180 | static int __init at91sam926x_pit_dt_init(struct device_node *node) |
| 181 | { | 181 | { |
| 182 | unsigned long pit_rate; | 182 | unsigned long pit_rate; |
| 183 | unsigned bits; | 183 | unsigned bits; |
| 184 | int ret; | 184 | int ret; |
| 185 | struct pit_data *data; | ||
| 186 | |||
| 187 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
| 188 | if (!data) | ||
| 189 | return -ENOMEM; | ||
| 190 | |||
| 191 | data->base = of_iomap(node, 0); | ||
| 192 | if (!data->base) { | ||
| 193 | pr_err("Could not map PIT address\n"); | ||
| 194 | return -ENXIO; | ||
| 195 | } | ||
| 196 | |||
| 197 | data->mck = of_clk_get(node, 0); | ||
| 198 | if (IS_ERR(data->mck)) { | ||
| 199 | pr_err("Unable to get mck clk\n"); | ||
| 200 | return PTR_ERR(data->mck); | ||
| 201 | } | ||
| 202 | |||
| 203 | ret = clk_prepare_enable(data->mck); | ||
| 204 | if (ret) { | ||
| 205 | pr_err("Unable to enable mck\n"); | ||
| 206 | return ret; | ||
| 207 | } | ||
| 208 | |||
| 209 | /* Get the interrupts property */ | ||
| 210 | data->irq = irq_of_parse_and_map(node, 0); | ||
| 211 | if (!data->irq) { | ||
| 212 | pr_err("Unable to get IRQ from DT\n"); | ||
| 213 | return -EINVAL; | ||
| 214 | } | ||
| 185 | 215 | ||
| 186 | /* | 216 | /* |
| 187 | * Use our actual MCK to figure out how many MCK/16 ticks per | 217 | * Use our actual MCK to figure out how many MCK/16 ticks per |
| @@ -236,46 +266,5 @@ static int __init at91sam926x_pit_common_init(struct pit_data *data) | |||
| 236 | 266 | ||
| 237 | return 0; | 267 | return 0; |
| 238 | } | 268 | } |
| 239 | |||
| 240 | static int __init at91sam926x_pit_dt_init(struct device_node *node) | ||
| 241 | { | ||
| 242 | struct pit_data *data; | ||
| 243 | int ret; | ||
| 244 | |||
| 245 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
| 246 | if (!data) | ||
| 247 | return -ENOMEM; | ||
| 248 | |||
| 249 | data->base = of_iomap(node, 0); | ||
| 250 | if (!data->base) { | ||
| 251 | pr_err("Could not map PIT address\n"); | ||
| 252 | return -ENXIO; | ||
| 253 | } | ||
| 254 | |||
| 255 | data->mck = of_clk_get(node, 0); | ||
| 256 | if (IS_ERR(data->mck)) | ||
| 257 | /* Fallback on clkdev for !CCF-based boards */ | ||
| 258 | data->mck = clk_get(NULL, "mck"); | ||
| 259 | |||
| 260 | if (IS_ERR(data->mck)) { | ||
| 261 | pr_err("Unable to get mck clk\n"); | ||
| 262 | return PTR_ERR(data->mck); | ||
| 263 | } | ||
| 264 | |||
| 265 | ret = clk_prepare_enable(data->mck); | ||
| 266 | if (ret) { | ||
| 267 | pr_err("Unable to enable mck\n"); | ||
| 268 | return ret; | ||
| 269 | } | ||
| 270 | |||
| 271 | /* Get the interrupts property */ | ||
| 272 | data->irq = irq_of_parse_and_map(node, 0); | ||
| 273 | if (!data->irq) { | ||
| 274 | pr_err("Unable to get IRQ from DT\n"); | ||
| 275 | return -EINVAL; | ||
| 276 | } | ||
| 277 | |||
| 278 | return at91sam926x_pit_common_init(data); | ||
| 279 | } | ||
| 280 | CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", | 269 | CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", |
| 281 | at91sam926x_pit_dt_init); | 270 | at91sam926x_pit_dt_init); |
