1// SPDX-License-Identifier: GPL-2.0 2// Copyright (c) 2018, The Linux Foundation. All rights reserved. 3 4#include <linux/kernel.h> 5#include <linux/init.h> 6#include <linux/module.h> 7#include <linux/platform_device.h> 8#include <linux/property.h> 9#include <linux/err.h> 10#include <linux/io.h> 11#include <linux/of.h> 12#include <linux/clk.h> 13#include <linux/clk-provider.h> 14 15static const struct clk_parent_data aux_parents[] = { 16 { .fw_name = "pll8_vote", .name = "pll8_vote" }, 17 { .fw_name = "pxo", .name = "pxo_board" }, 18}; 19 20static const u32 aux_parent_map[] = { 21 3, 22 0, 23}; 24 25static const struct of_device_id kpss_xcc_match_table[] = { 26 { .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL }, 27 { .compatible = "qcom,kpss-gcc" }, 28 {} 29}; 30MODULE_DEVICE_TABLE(of, kpss_xcc_match_table); 31 32static int kpss_xcc_driver_probe(struct platform_device *pdev) 33{ 34 struct device *dev = &pdev->dev; 35 void __iomem *base; 36 struct clk_hw *hw; 37 const char *name; 38 39 base = devm_platform_ioremap_resource(pdev, 0); 40 if (IS_ERR(base)) 41 return PTR_ERR(base); 42 43 if (device_get_match_data(&pdev->dev)) { 44 if (of_property_read_string_index(dev->of_node, 45 "clock-output-names", 46 0, &name)) 47 return -ENODEV; 48 base += 0x14; 49 } else { 50 name = "acpu_l2_aux"; 51 base += 0x28; 52 } 53 54 hw = devm_clk_hw_register_mux_parent_data_table(dev, name, aux_parents, 55 ARRAY_SIZE(aux_parents), 0, 56 base, 0, 0x3, 57 0, aux_parent_map, NULL); 58 if (IS_ERR(hw)) 59 return PTR_ERR(hw); 60 61 of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, hw); 62 63 return 0; 64} 65 66static struct platform_driver kpss_xcc_driver = { 67 .probe = kpss_xcc_driver_probe, 68 .driver = { 69 .name = "kpss-xcc", 70 .of_match_table = kpss_xcc_match_table, 71 }, 72}; 73module_platform_driver(kpss_xcc_driver); 74 75MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver"); 76MODULE_LICENSE("GPL v2"); 77MODULE_ALIAS("platform:kpss-xcc"); 78