···11+Broadcom BCM2835 auxiliary peripheral support22+33+This binding uses the common clock binding:44+ Documentation/devicetree/bindings/clock/clock-bindings.txt55+66+The auxiliary peripherals (UART, SPI1, and SPI2) have a small register77+area controlling clock gating to the peripherals, and providing an IRQ88+status register.99+1010+Required properties:1111+- compatible: Should be "brcm,bcm2835-aux"1212+- #clock-cells: Should be <1>. The permitted clock-specifier values can be1313+ found in include/dt-bindings/clock/bcm2835-aux.h1414+- reg: Specifies base physical address and size of the registers1515+- clocks: The parent clock phandle1616+1717+Example:1818+1919+ clocks: cprman@7e101000 {2020+ compatible = "brcm,bcm2835-cprman";2121+ #clock-cells = <1>;2222+ reg = <0x7e101000 0x2000>;2323+ clocks = <&clk_osc>;2424+ };2525+2626+ aux: aux@0x7e215004 {2727+ compatible = "brcm,bcm2835-aux";2828+ #clock-cells = <1>;2929+ reg = <0x7e215000 0x8>;3030+ clocks = <&clocks BCM2835_CLOCK_VPU>;3131+ };
···11+/*22+ * Copyright (C) 2015 Broadcom33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ */1414+1515+#include <linux/clk.h>1616+#include <linux/clk-provider.h>1717+#include <linux/clk/bcm2835.h>1818+#include <linux/module.h>1919+#include <linux/platform_device.h>2020+#include <dt-bindings/clock/bcm2835-aux.h>2121+2222+#define BCM2835_AUXIRQ 0x002323+#define BCM2835_AUXENB 0x042424+2525+static int bcm2835_aux_clk_probe(struct platform_device *pdev)2626+{2727+ struct device *dev = &pdev->dev;2828+ struct clk_onecell_data *onecell;2929+ const char *parent;3030+ struct clk *parent_clk;3131+ struct resource *res;3232+ void __iomem *reg, *gate;3333+3434+ parent_clk = devm_clk_get(dev, NULL);3535+ if (IS_ERR(parent_clk))3636+ return PTR_ERR(parent_clk);3737+ parent = __clk_get_name(parent_clk);3838+3939+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);4040+ reg = devm_ioremap_resource(dev, res);4141+ if (!reg)4242+ return -ENODEV;4343+4444+ onecell = devm_kmalloc(dev, sizeof(*onecell), GFP_KERNEL);4545+ if (!onecell)4646+ return -ENOMEM;4747+ onecell->clk_num = BCM2835_AUX_CLOCK_COUNT;4848+ onecell->clks = devm_kcalloc(dev, BCM2835_AUX_CLOCK_COUNT,4949+ sizeof(*onecell->clks), GFP_KERNEL);5050+ if (!onecell->clks)5151+ return -ENOMEM;5252+5353+ gate = reg + BCM2835_AUXENB;5454+ onecell->clks[BCM2835_AUX_CLOCK_UART] =5555+ clk_register_gate(dev, "aux_uart", parent, 0, gate, 0, 0, NULL);5656+5757+ onecell->clks[BCM2835_AUX_CLOCK_SPI1] =5858+ clk_register_gate(dev, "aux_spi1", parent, 0, gate, 1, 0, NULL);5959+6060+ onecell->clks[BCM2835_AUX_CLOCK_SPI2] =6161+ clk_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);6262+6363+ of_clk_add_provider(pdev->dev.of_node, of_clk_src_onecell_get, onecell);6464+6565+ return 0;6666+}6767+6868+static const struct of_device_id bcm2835_aux_clk_of_match[] = {6969+ { .compatible = "brcm,bcm2835-aux", },7070+ {},7171+};7272+MODULE_DEVICE_TABLE(of, bcm2835_aux_clk_of_match);7373+7474+static struct platform_driver bcm2835_aux_clk_driver = {7575+ .driver = {7676+ .name = "bcm2835-aux-clk",7777+ .of_match_table = bcm2835_aux_clk_of_match,7878+ },7979+ .probe = bcm2835_aux_clk_probe,8080+};8181+builtin_platform_driver(bcm2835_aux_clk_driver);8282+8383+MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");8484+MODULE_DESCRIPTION("BCM2835 auxiliary peripheral clock driver");8585+MODULE_LICENSE("GPL v2");
+17
include/dt-bindings/clock/bcm2835-aux.h
···11+/*22+ * Copyright (C) 2015 Broadcom Corporation33+ *44+ * This program is free software; you can redistribute it and/or55+ * modify it under the terms of the GNU General Public License as66+ * published by the Free Software Foundation version 2.77+ *88+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any99+ * kind, whether express or implied; without even the implied warranty1010+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1111+ * GNU General Public License for more details.1212+ */1313+1414+#define BCM2835_AUX_CLOCK_UART 01515+#define BCM2835_AUX_CLOCK_SPI1 11616+#define BCM2835_AUX_CLOCK_SPI2 21717+#define BCM2835_AUX_CLOCK_COUNT 3