]> Git Repo - linux.git/blame - drivers/clk/bcm/clk-bcm2835-aux.c
Merge tag 'drm-misc-next-2018-06-27' of git://anongit.freedesktop.org/drm/drm-misc...
[linux.git] / drivers / clk / bcm / clk-bcm2835-aux.c
CommitLineData
5e63dcc7
EA
1/*
2 * Copyright (C) 2015 Broadcom
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <linux/clk.h>
16#include <linux/clk-provider.h>
5e63dcc7
EA
17#include <linux/module.h>
18#include <linux/platform_device.h>
19#include <dt-bindings/clock/bcm2835-aux.h>
20
21#define BCM2835_AUXIRQ 0x00
22#define BCM2835_AUXENB 0x04
23
24static int bcm2835_aux_clk_probe(struct platform_device *pdev)
25{
26 struct device *dev = &pdev->dev;
b19f009d 27 struct clk_hw_onecell_data *onecell;
5e63dcc7
EA
28 const char *parent;
29 struct clk *parent_clk;
30 struct resource *res;
31 void __iomem *reg, *gate;
32
33 parent_clk = devm_clk_get(dev, NULL);
34 if (IS_ERR(parent_clk))
35 return PTR_ERR(parent_clk);
36 parent = __clk_get_name(parent_clk);
37
38 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
39 reg = devm_ioremap_resource(dev, res);
4d3ac666
VZ
40 if (IS_ERR(reg))
41 return PTR_ERR(reg);
5e63dcc7 42
0ed2dd03
KC
43 onecell = devm_kmalloc(dev,
44 struct_size(onecell, hws,
45 BCM2835_AUX_CLOCK_COUNT),
46 GFP_KERNEL);
5e63dcc7
EA
47 if (!onecell)
48 return -ENOMEM;
b19f009d 49 onecell->num = BCM2835_AUX_CLOCK_COUNT;
5e63dcc7
EA
50
51 gate = reg + BCM2835_AUXENB;
b19f009d
SB
52 onecell->hws[BCM2835_AUX_CLOCK_UART] =
53 clk_hw_register_gate(dev, "aux_uart", parent, 0, gate, 0, 0, NULL);
5e63dcc7 54
b19f009d
SB
55 onecell->hws[BCM2835_AUX_CLOCK_SPI1] =
56 clk_hw_register_gate(dev, "aux_spi1", parent, 0, gate, 1, 0, NULL);
5e63dcc7 57
b19f009d
SB
58 onecell->hws[BCM2835_AUX_CLOCK_SPI2] =
59 clk_hw_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);
5e63dcc7 60
b19f009d
SB
61 return of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_onecell_get,
62 onecell);
5e63dcc7
EA
63}
64
65static const struct of_device_id bcm2835_aux_clk_of_match[] = {
66 { .compatible = "brcm,bcm2835-aux", },
67 {},
68};
69MODULE_DEVICE_TABLE(of, bcm2835_aux_clk_of_match);
70
71static struct platform_driver bcm2835_aux_clk_driver = {
72 .driver = {
73 .name = "bcm2835-aux-clk",
74 .of_match_table = bcm2835_aux_clk_of_match,
75 },
76 .probe = bcm2835_aux_clk_probe,
77};
78builtin_platform_driver(bcm2835_aux_clk_driver);
79
80MODULE_AUTHOR("Eric Anholt <[email protected]>");
81MODULE_DESCRIPTION("BCM2835 auxiliary peripheral clock driver");
82MODULE_LICENSE("GPL v2");
This page took 0.20218 seconds and 4 git commands to generate.